I'd like to use the ols()
(ordinary least squares) function from the rms
package to do a multivariate linear regression, but I would not like it to calculate the intercept. Using lm()
the syntax would be like:
model <- lm(formula = z ~ 0 + x + y, data = myData)
where the 0
stops it from calculating an intercept, and only two coefficients are returned, on for x
and the other for y
. How do I do this when using ols()
? Trying
model <- ols(formula = z ~ 0 + x + y, data = myData)
did not work, it still returns an intercept and a coefficient each for x
and y
.
It has five columns. For this example, can only use the first three columns:
model <- ols(formula = CorrEn ~ intEn_anti_ncp + intEn_par_ncp, data = ccd)
Thanks!
rms::ols
uses rms:::Design
instead of model.frame.default
. Design
is called with the default of intercept = 1
, so there is no (obvious) way to specify that there is no intercept. I assume there is a good reason for this, but you can try changing ols
using trace
.
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.