predict() with arbitrary coefficients in r

前端 未结 3 761
庸人自扰
庸人自扰 2020-12-10 07:51

I\'ve got some coefficients for a logit model set by a non-r user. I\'d like to import those coefficients into r and generate some goodness of fit estimates on the same data

3条回答
  •  心在旅途
    2020-12-10 08:14

    Or, you can use something like this:

    fit <- lm(Y ~ A + B + C, data=fakedata)

    fit$coefficients <- c(1, 2, 3) # this would change the coefficients for A, B, C to 1, 2 and 3, respectively.

    Y_hat_new <- predict(fit, new_fakedata) # this Y_hat_new will be calculated as your new predicted outcome given the new coefficients and/or new_fakedata.

    The results should be the same if you follow the model.matrix route.

提交回复
热议问题