thanks Jorge.  I appreciate your quick help.


Will this work if I have 20 columns of data but my regression only has 5 
variables?



I am looking for something generic where I can give it my model and test data 
and get back a vector of the multiplied coefficients (with no hard coding).  
When predict is called with an input model and data, R must be multiplying all 
co-efficients times variables and summing the number but is there a way to get 
components of the regressiom terms stored in a matrix before they are added?



The idea is to build n models with various terms and after producing a 
prediction list the top 3 variables that had the biggest impact in that 
particular set of predictor values.



e.g. if I build a model to predict default of loans I would then need to list 
the top factors in the model that can be used to explain why the loan is risky. 
 With 10-16 variables which can be present or not for each case there be a 
different 2 or 3 variables that led to the said prediction.



Dhruv





 --- On Mon 07/07, Jorge Ivan Velez < [EMAIL PROTECTED] > wrote:

From: Jorge Ivan Velez [mailto: [EMAIL PROTECTED]

To: [EMAIL PROTECTED]

Date: Mon, 7 Jul 2008 20:12:53 -0400

Subject: Re: [R] question on lm or glm matrix of coeficients X test data terms



Dear Dhruv,Try also:# data setset.seed(123)X=matrix(rpois(10,10),ncol=2)# 
Function to estimate your 
outcomeoutcome=function(x,betas){if(length(x)!=length(betas)) stop("x and betas 
are of different length!")

y=x*betasy}# outcome for beta1=0.05 and 
beta2=0.6t(apply(X,1,outcome,betas=c(0.05,0.6)))# outcome for beta1=5 and 
beta2=6

t(apply(X,1,outcome,betas=c(5,6)))

HTH,JorgeOn 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



______________________________________________

R-help@r-project.org 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.

______________________________________________
R-help@r-project.org 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.

Reply via email to