简体   繁体   中英

Conduct a linear hypothesis test on the estimated coefficients of a logistic regression in R

I have the logistic regression of the form

Y=f(X;\theta)=\alpha+\beta X

where

\theta={\alpha,\beta}

The corresponding R code is the following.

Regression_hat<-glm(Y~X,family=binomial(link='logit'))

I know that in order to test the joint hypothesis testH_{0}:\hat{\alpha}=0 \; \& \; \hat{\beta}=0

the linearHypothesis test can be used with the following form:

linearHypothesis(Regression_hat,c("(Intercept)=0","X=0"),test=c("F"))

I would like to test (jointly) the hypothesis that both estimated parameters equal to two arbitrary values respectively. These two values are stored under different variable (eg V1 and V2 ) names in R although using variable names in the above code ( linearHypothesis(Regression_hat,c("(Intercept)=V1","X=V2"),test=c("F")) ) does not work.

Try

linearHypothesis(Regression_hat, paste(c("(Intercept)", "X"), "=", c(V1, V2)), test = "F")

The issue is that writing, eg, "X=V2" doesn't make X2 look like a variable; it's just a part of this character. Using paste helps you to construct, eg, "X=3" when V1 takes value 3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM