From: DS <ds5j_at_excite.com>

Date: Tue, 08 Jul 2008 21:32:56 -0400 (EDT)

R-help_at_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. Received on Wed 09 Jul 2008 - 01:41:27 GMT

Date: Tue, 08 Jul 2008 21:32:56 -0400 (EDT)

thanks Jorge. This is great!

regards,

Dhruv

- On Tue 07/08, Jorge Ivan Velez < jorgeivanvelez_at_gmail.com > wrote:

From: Jorge Ivan Velez [mailto: jorgeivanvelez_at_gmail.com]

To: ds5j_at_excite.com

Date: Tue, 8 Jul 2008 20:45:06 -0400

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

Hi Dhruv,Thanks for the data. Here is what you need so far:# Data setyourdata=structure(c(0.024575733, 0.775009533, 0.216823408, 0.413676529, 0.270053406, 0.579946123, 0.634013362, 0.928518128, 0.405825012,

0.862204203, 0.856558209, 0.187865722, 0.818774004, 0.918802224, 0.469496189, 0.240583922, 0.390818789, 0.767969261, 0.13339806, 0.986023924, 0.442655239, 0.437441939, 0.313678293, 0.952285599, 0.528433974, 0.328609537, 0.84584467, 0.608194527, 0.96139021,

0.485592658, 0.251827955, 0.289777559), .Dim = c(4L, 8L), .Dimnames = list( NULL, c("A", "B", "C", "D", "E", "F", "A:B", "G:H")))

# Function to select the top k values (names)ftopk= function(x,top=3){ res=cnames[order(x, decreasing = TRUE)][1:top] paste(res,collapse=";",sep="")}# Application of the function using the top 3 rows

topk=apply(yourdata,1,ftopk,top=3)# Resultdata.frame(yourdata,topk) A B C D E F A.B G.H topk1 0.02457573 0.2700534 0.4058250 0.8187740 0.3908188 0.4426552 0.5284340 0.9613902 G:H;D;A:B

2 0.77500953 0.5799461 0.8622042 0.9188022 0.7679693 0.4374419 0.3286095 0.4855927 D;C;A3 0.21682341 0.6340134 0.8565582 0.4694962 0.1333981 0.3136783 0.8458447 0.2518280 C;A:B;B4 0.41367653 0.9285181 0.1878657 0.2405839 0.9860239 0.9522856 0.6081945 0.2897776 E;F;B

HTH,JorgeOn Tue, Jul 8, 2008 at 8:19 PM, DS <ds5j_at_excite.com> wrote:

Hi Jorge,

I am attaching some sample data that looks like the coefficient matrix.

In the spreadsheet for each row I have listed the column names I would want to extract for each row. (the ones with the highest values in the row).

hope this helps.

thanks

regards,

Dhruv

- On Tue 07/08, Jorge Ivan Velez < jorgeivanvelez_at_gmail.com > wrote:

From: Jorge Ivan Velez [mailto: jorgeivanvelez_at_gmail.com]

To: ds5j_at_excite.com

Date: Tue, 8 Jul 2008 19:36:52 -0400

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

Dear Dhruv, Could you please send me part your data set m? Just 10-20 rows, so I'll have any idea about what you have and what you'd like. I hope you don't mind.Thanks a lot,Jorge

On Tue, Jul 8, 2008 at 7:33 PM, DS wrote:

Hi,

I found some of what I was looking for.

using the following I can get a matrix of regression coefficient multiplied out by the variable data.

g wrote:

From: Jorge Ivan Velez [mailto: jorgeivanvelez_at_gmail.com]

To: ds5j_at_excite.com

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 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_at_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_at_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. Received on Wed 09 Jul 2008 - 01:41:27 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 09 Jul 2008 - 03:31:34 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*