Hi everyone,
I have student scores for two test components (Component1 & Component2) from 485 schools. Using a linear regression model of Component1 on Component2, I want to predict scores for students who missed Component1 or whose marks were not recorded. The regression equation will be school-specific and used to generate predicted scores, recorded in a variable called "Predicted_Scores." The plan is for Stata to regress Component1 on Component2, predict missing Component1 scores for each school one-by-one, and store the predictions in a single variable named "Predicted_Scores." I've written the code bellow to accomplish this, but Stata is applying the same regression coefficients to all schools. Can you assist me in resolving this issue?
Code:
gen Predicted_Scores = .
forvalues i = 1/ 485 {
regress Component1 Component2 i.School_Code if School_Code == `i'
predict predicted_values, xb
replace Predicted_Scores = predicted_values if School_Code == `i'
}
Related Posts with Predicting values using Simple Linear Regression on Categorical Data
Help with Estout table showing 3 values vertically, in 3 rowsHi, I am trying to get my table to look like the following in a .tex file, using estout. This shows…
Petersen 2009 - Estimating standard errors in panel data setsHello all, I'm having some trouble at replicating this paper Peterson 2009 and have simulation.do f…
Dropping duplicatesHie everyone l am using the drug stock out data with the name of facility, year, number of days sto…
Multiple variables using grmapDear all, I am working with the command grmap, and I have no problems in creating maps. However, I …
Matching based on propensity score taking care of yearDear statalisters I'm facing with a lot of difficulties to implement matching with propensity scores…
Subscribe to:
Post Comments (Atom)
0 Response to Predicting values using Simple Linear Regression on Categorical Data
Post a Comment