# Example 8.9, Determinants of Personal Computer Ownership # Data set: gpa1 # Function for result reporting source("_report.R") # Load the data, create new variable and estimate the model load("gpa1.Rdata") data$parcoll=as.numeric(!(data$fathcoll==0&data$mothcoll==0)) model1=lm(PC~hsGPA+ACT+parcoll,data=data) dig1=c(4,3,4,3,4) # Describe the model cat("Model to estimate: PC = beta0 + beta1 * hsGPA + beta2 * ACT + beta3 * parcoll + u", "\nwhere PC is ", paste(desc[desc[,1]=="PC",2]), "\nhsGPA is ", paste(desc[desc[,1]=="hsGPA",2]), "\nACT is ", paste(desc[desc[,1]=="ACT",2]), "\nand parcoll is =1 if at least one parent attended college", sep="") # Report results { cat("The estimated regression line is") reportreg(model1,dig1,HC=T) } # Estimate by WLS data$fitted=model1$fitted.values model2=lm(PC~hsGPA+ACT+parcoll,weight=1/(fitted*(1-fitted)),data=data) dig2=c(3,3,4,3,4) { cat("There is little difference between both sets of standard errors. Nevertheless, we estimate the model again by WLS. Because all of the OLS fitted values are inside the unit interval, no adjustments are needed. The estimated regression line is") reportreg(model2,dig2) } # Interpretation cat("There are no important differences in the OLS and WLS estimates. The only significant explanatory variable is parcoll, and the magnitudes of its coefficients in both estimates are close")