Dear Dhruv,
Try this:
# data set
set.seed(123)
X=matrix(rpois(10,10),ncol=2)
X
[,1] [,2]
[1,] 8 15
[2,] 9 11
[3,] 14 5
[4,] 10 4
[5,] 10 13
# outcome
t(apply(X,1,function(x,betas){
if(length(x)!=length(betas)) stop("x and betas are of different length!")
y=x*betas
y
},betas=c(0.05,0.6)))
[,1] [,2]
[1,] 0.40 9.0
[2,] 0.45 6.6
[3,] 0.70 3.0
[4,] 0.50 2.4
[5,] 0.50 7.8
HTH,
Jorge
On Mon, Jul 7, 2008 at 7:56 PM, DS <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> is there an easy way to get the calculated weights in a regression
> equation?
>
>
>
> for e.g.
>
> if my model has 2 variables 1 and 2 with coefficient .05 and .6
>
> how can I get the computed values for a test dataset for each coefficient?
>
> data
>
> var1,var2
>
> 10,100
>
>
>
> so I want to get .5, 60 back in a vector. This is a one row example but I
> would want to get a matrix of multiplied out coefficients and terms for use
> in comparing contribution of variables to final score. As in a scorecard
> using logistic regression.
>
>
>
> Please advise.
>
> thanks
>
> Dhruv
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.