svymultinom | R Documentation |
svymultinom
uses the withReplicates function to compute the replicate-based
estimate of the variance-covariance matrix of coefficients for a multinomial regression fitted by
multinom.
svymultinom(formula = NULL, weights = NULL, data = NULL)
## S3 method for class 'svymultinom'
coef(object, ...)
## S3 method for class 'svymultinom'
vcov(object, ...)
## S3 method for class 'svymultinom'
formula(x, ...)
## S3 method for class 'svymultinom'
predict(object, ...)
## S3 method for class 'svymultinom'
model.frame(formula, ...)
## S3 method for class 'svymultinom'
print(x, ...)
## S3 method for class 'svymultinom'
summary(object, ...)
## S3 method for class 'summary.svymultinom'
print(x, digits = 4, ...)
## S3 method for class 'svymultinom'
update(object, ..., evaluate = TRUE)
formula |
regression formula |
weights |
weights for regression |
data |
dataset for regression |
object |
an object of class 'svymultinom' |
... |
additional arguments |
x |
an object of class 'svymultinom' |
digits |
minimal number of significant digits. See print.default. |
evaluate |
a logical value. If |
An object of class svymultinom
is returned:
call |
the function call, |
NAIVEreg |
the naive multinomial regression object, |
vcov |
the replicate-based estimate of the variance-covariance matrix of coefficients, |
...
coef(svymultinom)
: Extract coefficients
vcov(svymultinom)
: Extract the var-cov matrix of coefficients
formula(svymultinom)
: Extract the regression formula
predict(svymultinom)
: Predict with new data
model.frame(svymultinom)
: Extract the model frame
print(svymultinom)
: Print results of svymultinom
nicely
summary(svymultinom)
: Summarize results of svymultinom
nicely
update(svymultinom)
: Update svymultinom
print(summary.svymultinom)
: Print summary of svymultinom
nicely
multinom, withReplicates
## Not run:
rm(list=ls())
library(CMAverse)
# multinom
n <- 1000
x1 <- rnorm(n, mean = 0, sd = 1)
x2 <- rnorm(n, mean = 1, sd = 1)
x3 <- rbinom(n, size = 1, prob = 0.4)
linearpred1 <- 1 + 0.3 * x1 - 0.5 * x2 - 0.2 * x3
linearpred2 <- 2 + 1 * x1 - 2 * x2 - 1 * x3
py2 <- exp(linearpred1) / (1 + exp(linearpred1) + exp(linearpred2))
py3 <- exp(linearpred2) / (1 + exp(linearpred1) + exp(linearpred2))
py1 <- 1 - py2 - py3
y <- sapply(1:n, function(x) sample(size = 1, c(1:3), prob = c(py1[x], py2[x], py3[x])))
w <- ifelse(x3 == 0, 0.4, 0.6)
data <- data.frame(x1 = x1, x2 = x2, x3 = x3, y = y)
reg <- svymultinom(y ~ x1 + x2 + x3, weights = w, data = data)
coef(reg)
vcov(reg)
formula(reg)
predict(reg, newdata = data[1, ], type = "probs")
model.frame(reg)
summary(reg)
update(reg, weights = w[1:500], data = data[1:500, ])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.