Description Usage Arguments Details Value Author(s) References See Also Examples

Fits a linear model that uses weights and variance estimates appropriate for the data.

1 2 3 4 5 |

`formula` |
a |

`data` |
an |

`weightVar` |
a character indicating the weight variable to use (see Details).
The |

`relevels` |
a list. Used to change the contrasts from the default treatment contrasts to the treatment contrasts with a chosen omitted group (the reference group). The name of each element should be the variable name, and the value should be the group to be omitted (the reference group). |

`varMethod` |
a character set to “jackknife” or “Taylor” that indicates the variance estimation method to be used. See Details. |

`jrrIMax` |
when using the jackknife variance estimation method, the default estimation option, |

`omittedLevels` |
a logical value. When set to the default value of |

`defaultConditions` |
a logical value. When set to the default value of |

`recode` |
a list of lists to recode variables. Defaults to |

`returnVarEstInputs` |
a logical value set to |

`returnNumberOfPSU` |
a logical value set to |

`standardizeWithSamplingVar` |
a logical value indicating if the standardized coefficients
should have the variance of the regressors and outcome measured
with sampling variance. Defaults to |

This function implements an estimator that correctly handles left-hand side variables that are either numeric or plausible values, and allows for survey sampling weights and estimates variances using the jackknife replication method. The vignette titled Statistics describes estimation of the reported statistics.

Regardless of the variance estimation, the coefficients are estimated using the sample weights according to the sections “Estimation of Weighted Means When Plausible Values Are Not Present” or “Estimation of Weighted Means When Plausible Values Are Present,” depending on if there are assessment variables or variables with plausible values in them.

How the standard errors of the coefficients are estimated depends on the
value of `varMethod`

and the presence of plausible values (assessment variables),
But once it is obtained, the *t* statistic
is given by

*t=\frac{\hat{β}}{√{\mathrm{var}(\hat{β})}}*

where
* \hat{β} * is the estimated coefficient and *\mathrm{var}(\hat{β})* is
the variance of that estimate.

The **coefficient of determination ( R-squared value)** is similarly estimated by finding
the average

Standardized regression coefficients can be returned in a call to `summary`

,
by setting the argument `src`

to `TRUE`

. See Examples.

By default, the standardized coefficients are calculated using standard
deviations of the variables themselves, including averaging the standard
deviation across any plausible values. When `standardizeWithSamplingVar`

is set to `TRUE`

the variance of the standardized coefficient is
calculated similar to a regression coefficient and therefore includes the
sampling variance in the variance estimate of the outcome variable.

All variance estimation methods are shown in the vignette titled
Statistics.
When `varMethod`

is set to `jackknife`

and the predicted
value does not have plausible values, the variance of the coefficients
is estimated according to the section
“Estimation of Standard Errors of Weighted Means When
Plausible Values Are Not Present, Using the Jackknife Method.”

When plausible values are present and `varMethod`

is `jackknife`

, the
variance of the coefficients is estimated according to the section
“Estimation of Standard Errors of Weighted Means When
Plausible Values Are Present, Using the Jackknife Method.”

When plausible values are not present and `varMethod`

is `Taylor`

, the
variance of the coefficients is estimated according to the section
“Estimation of Standard Errors of Weighted Means When Plausible
Values Are Not Present, Using the Taylor Series Method.”

When plausible values are present and `varMethod`

is `Taylor`

, the
variance of the coefficients is estimated according to the section
“Estimation of Standard Errors of Weighted Means When Plausible
Values Are Present, Using the Taylor Series Method.”

An `edsurvey.lm`

with the following elements:

`call` |
the function call |

`formula` |
the formula used to fit the model |

`coef` |
the estimates of the coefficients |

`se` |
the standard error estimates of the coefficients |

`Vimp` |
the estimated variance from uncertainty in the scores (plausible value variables) |

`Vjrr` |
the estimated variance from sampling |

`M` |
the number of plausible values |

`varm` |
the variance estimates under the various plausible values |

`coefm` |
the values of the coefficients under the various plausible values |

`coefmat` |
the coefficient matrix (typically produced by the summary of a model) |

`r.squared` |
the coefficient of determination |

`weight` |
the name of the weight variable |

`npv` |
the number of plausible values |

`jrrIMax` |
the |

`njk` |
the number of jackknife replicates used; set to |

`varMethod` |
one of |

`residuals` |
residuals from the average regression coefficients |

`PV.residuals` |
residuals from the by plausible value coefficients |

`PV.fitted.values` |
fitted values from the by plausible value coefficients |

`B` |
imputation variance covariance matrix, before multiplication by (M+1)/M |

`U` |
sampling variance covariance matrix |

`rbar` |
average relative increase in variance; see van Buuren (2012, eq. 2.29) |

`nPSU` |
number of PSUs used in calculation |

`n0` |
number of rows on |

`nUsed` |
number of observations with valid data and weights larger than zero |

`data` |
data used for the computation |

`Xstdev` |
standard deviations of regressors, used for computing standardized
regression coefficients when |

`varSummary` |
the result of running |

`varEstInputs` |
when |

`standardizeWithSamplingVar` |
when |

Paul Bailey

Binder, D. A. (1983). On the variances of asymptotically normal estimators from complex surveys. *International Statistical Review*, *51*(3), 279–292.

Rubin, D. B. (1987). *Multiple imputation for nonresponse in surveys*. New York, NY: Wiley.

van Buuren, S. (2012). *Flexible imputation of missing data*. New York, NY: CRC Press.

Weisberg, S. (1985). *Applied linear regression* (2nd ed.). New York, NY: Wiley.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ```
## Not run:
# read in the example data (generated, not real student data)
sdf <- readNAEP(system.file("extdata/data", "M36NT2PM.dat", package = "NAEPprimer"))
# By default uses jackknife variance method using replicate weights
lm1 <- lm.sdf(composite ~ dsex + b017451, data=sdf)
lm1
# The summary function displays detailed results
summary(lm1)
# To show standardized regression coefficients
summary(lm1, src=TRUE)
# To specify a variance method, use varMethod
lm2 <- lm.sdf(composite ~ dsex + b017451, data=sdf, varMethod="Taylor")
lm2
summary(lm2)
# Use relevel to set a new omitted category
lm3 <- lm.sdf(composite ~ dsex + b017451, data=sdf, relevels=list(dsex="Female"))
summary(lm3)
# Use recode to change values for specified variables
lm4 <- lm.sdf(composite ~ dsex + b017451, data=sdf,
recode=list(b017451=list(from=c("Never or hardly ever",
"Once every few weeks",
"About once a week"),
to=c("Infrequently")),
b017451=list(from=c("2 or 3 times a week","Every day"),
to=c("Frequently"))))
# Note: "Infrequently" is the dropped level for the recoded b017451
summary(lm4)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.