[R] SOM library - where do I find it
R version 2.9.2 (2009-08-24) - for windows > library(SOM) Error in library(SOM) : there is no package called 'SOM' Where can I get the SOM library from? Thanks in advance -- View this message in context: http://old.nabble.com/SOM-library---where-do-I-find-it-tp26415633p26415633.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Logistic and Linear Regression Libraries
OK, I think I've figured it out, the predict of lrm didn't seem to pass it through the logistic function. If I do this then the value is similar to that of lm. Is this by design? Why would it be so? 1 / (1 + Exp(-1 * 3.38)) = 0.967 tdm wrote: > > > Anyway, do you know why the lrm predict give me a values of 3.38? > > -- View this message in context: http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26141558.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Logistic and Linear Regression Libraries
Hi Bill, Thanks for you comments. You may be right in that my ability to use the software may be the problem. I was using lm to fit a model with 'target' values of 0 or 1. I then discovered there was a lrm model as well, so just replaced lm with lrm and expected it to be fine. Then I found that the lrm model was predicting values greater than 1 for logistic regression - what am I doing wrong? Initially I was just looking at AUC, which are similar for both models, although different enough for me to be concerned. My data is highly correlated so I want to use a Hessian based algorithm rather then a non-hessian based algorithm, which is why I asked the initial question as to what other logistic regression models existed in R. Anyway, do you know why the lrm predict give me a values of 3.38? model_lr <- lm(as.formula(paste(mytarget, " ~ . ")) , data=df_train) model_lrA <- lrm(as.formula(paste(mytarget, " ~ . ")) , data=df_train) scores_lr_test <- predict(model_lr, df_test) scores_lr_train <- predict(model_lr, df_train) scores_lrA_test <- predict(model_lrA, df_test) scores_lrA_train <- predict(model_lrA, df_train) print("scores") print(scores_lr_train[1]) print("scoresA") print(scores_lrA_train[1]) print(colAUC(scores_lr_train,trainY)) print(colAUC(scores_lrA_train,trainY)) print(colAUC(scores_lr_test,testY)) print(colAUC(scores_lrA_test,testY)) [1] "scores" 1 0.9887154 [1] "scoresA" 1 3.389009 [,1] 0 vs. 1 0.9448262 [,1] 0 vs. 1 0.9487878 [,1] 0 vs. 1 0.9346953 [,1] 0 vs. 1 0.9357858 1 of 1[1] "" Bill.Venables wrote: > > glm is not, and never was. part of the MASS package. It's in the stats > package. > > Have you sorted out why there is a "big difference" between the results > you get using glm and lrm? > > Are you confident it is due to the algorithms used and not your ability to > use the software? > > To be helpful, if disappointing, I think the answer to your question is > "no". You will need to seek out the algorithms from the published > information on them individually. > > W. > > From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On > Behalf Of tdm [ph...@philbrierley.com] > Sent: 31 October 2009 16:53 > To: r-help@r-project.org > Subject: [R] Logistic and Linear Regression Libraries > > Hi all, > > I'm trying to discover the options available to me for logistic and linear > regression. I'm doing some tests on a dataset and want to see how > different > flavours of the algorithms cope. > > So far for logistic regression I've tried glm(MASS) and lrm (Design) and > found there is a big difference. Is there a list anywhere detailing the > options available which details the specific algorithms used? > > Thanks in advance, > > Phil > > > > -- > View this message in context: > http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26140248.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > > -- View this message in context: http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26141353.html Sent from the R help mailing list archive at Nabble.com. __ 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] Logistic and Linear Regression Libraries
Hi all, I'm trying to discover the options available to me for logistic and linear regression. I'm doing some tests on a dataset and want to see how different flavours of the algorithms cope. So far for logistic regression I've tried glm(MASS) and lrm (Design) and found there is a big difference. Is there a list anywhere detailing the options available which details the specific algorithms used? Thanks in advance, Phil -- View this message in context: http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26140248.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] plotting labels (not values) on xy plot
Thanks Jim - that worked. Jim Lemon-2 wrote: > > On 10/20/2009 01:10 PM, tdm wrote: >> I have 2 vectors, x and y and have done an xy plot. >> >> I want to plot the label (name?) of the vector on the plot rather than >> the >> value. >> >> text(x,y, labels = x) >> >> gives me the value of x. >> >> text(x,y, labels = labels(x)) >> >> gives me something like c("text1","text2"..) plotted for each point >> >> text(x,y, labels = names(x)) >> >> gives nothing >> >> print(x) gives me >> >> [,1] >> text10.0 >> text20.0 >> text3 -0.029027359 >> text4 -0.088602806 >> >> >> so how do 'text1' written rather than the value? I know there is a way >> but I >> am just guessing at the moment. >> >> Any pointers greatly appreciated. >> >> >> >> >> >> > Hi Phil, > It looks like you have a 4x1 matrix. My first guess would be: > > text(x,y,rownames(x)) > > Jim > > __ > 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. > > -- View this message in context: http://www.nabble.com/plotting-labels-%28not-values%29-on-xy-plot-tp25968696p25969146.html Sent from the R help mailing list archive at Nabble.com. __ 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] plotting labels (not values) on xy plot
I have 2 vectors, x and y and have done an xy plot. I want to plot the label (name?) of the vector on the plot rather than the value. text(x,y, labels = x) gives me the value of x. text(x,y, labels = labels(x)) gives me something like c("text1","text2"..) plotted for each point text(x,y, labels = names(x)) gives nothing print(x) gives me [,1] text10.0 text20.0 text3 -0.029027359 text4 -0.088602806 so how do 'text1' written rather than the value? I know there is a way but I am just guessing at the moment. Any pointers greatly appreciated. -- View this message in context: http://www.nabble.com/plotting-labels-%28not-values%29-on-xy-plot-tp25968696p25968696.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] modifying model coefficients
Thanks for the tip. I actually had to learn a bit of matrix multiplication and ended up calculating the RMSE this way. scores_lr <- t(coeffs_alldata) %*% t(df_train) rmseTrain <- (mean(((scores_lr)- trainY)^2))^0.5 full script and results here if you are interested. http://ausdm09.freeforums.org/post34.html#p34 tdm wrote: > > I have build a model but want to then manipulate the coefficients in some > way. > > I can extract the coefficients and do the changes I need, but how do I > then put these new coefficients back in the model so I can use the predict > function? > > my_model <- lm(x ~ . , data=my_data) > my_scores <- predict(my_model, my_data) > > my_coeffs <- coef(my_model) > > ## here we manipulate my_coeffs > ## and then want to set the my_model > ## coefficients to the new values so we > ## predict using the new values > > my_model.coefs <- my_coeffs ?? how is this done? > > ?? so that this will work with the new coefficients > my_scores_new <- predict(my_model, my_data) > > Any code snippets would be appreciated very much. > > -- View this message in context: http://www.nabble.com/modifying-model-coefficients-tp25952879p25964671.html Sent from the R help mailing list archive at Nabble.com. __ 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] modifying model coefficients
I have build a model but want to then manipulate the coefficients in some way. I can extract the coefficients and do the changes I need, but how do I then put these new coefficients back in the model so I can use the predict function? my_model <- lm(x ~ . , data=my_data) my_scores <- predict(my_model, my_data) my_coeffs <- coef(my_model) ## here we manipulate my_coeffs ## and then want to set the my_model ## coefficients to the new values so we ## predict using the new values my_model.coefs <- my_coeffs ?? how is this done? ?? so that this will work with the new coefficients my_scores_new <- predict(my_model, my_data) Any code snippets would be appreciated very much. -- View this message in context: http://www.nabble.com/modifying-model-coefficients-tp25952879p25952879.html Sent from the R help mailing list archive at Nabble.com. __ 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] populating an array
Hi, Can someone please give me a pointer as to how I can set values of an array? Why does the code below not work? my_array <- array(dim=c(2,2)) my_array[][] = 0 my_array [,1] [,2] [1,]00 [2,]00 for(i in seq(1,2,by=1)){ for(j in seq(1,2,by=1)){ my_array[i][j] = 5 } } Warning messages: 1: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length 2: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length my_array [,1] [,2] [1,]50 [2,]50 -- View this message in context: http://www.nabble.com/populating-an-array-tp25903190p25903190.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] field index given name.
Thanks - would never have guessed that. I eventually got the following to do what I want... > colprob <- array(dim=NCOL(iris)) > for(i in 1:NCOL(iris)){ + colprob[i]= + ifelse(names(iris)[i] == 'Species',1,0.5) + } > colprob [1] 0.5 0.5 0.5 0.5 1.0 Schalk Heunis-2 wrote: > > Hi Phil > Try the following >> which(names(iris)=='Species') > [1] 5 > > HTH > Schalk Heunis > > On Mon, Oct 12, 2009 at 8:53 AM, tdm wrote: > >> >> Hi, >> >> How do I access the index number of a field given I only know the field >> name? >> >> eg - I want to set the probability of the field 'species' higher than the >> other fields to use in sampling. >> >> > colprob <- array(dim=NCOL(iris)) >> > for(i in 1:NCOL(iris)){colprob[i]=0.5} >> > colprob[iris$species] = 1 #this doesn't work >> > colprob >> [1] 0.5 0.5 0.5 0.5 0.5 >> >> >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/field-index-given-name.-tp25851216p25851216.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> 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. >> > > [[alternative HTML version deleted]] > > __ > 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. > > -- View this message in context: http://www.nabble.com/field-index-given-name.-tp25851216p25851466.html Sent from the R help mailing list archive at Nabble.com. __ 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] field index given name.
Hi, How do I access the index number of a field given I only know the field name? eg - I want to set the probability of the field 'species' higher than the other fields to use in sampling. > colprob <- array(dim=NCOL(iris)) > for(i in 1:NCOL(iris)){colprob[i]=0.5} > colprob[iris$species] = 1 #this doesn't work > colprob [1] 0.5 0.5 0.5 0.5 0.5 -- View this message in context: http://www.nabble.com/field-index-given-name.-tp25851216p25851216.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] field names as function parameters
Thanks, just the clue I needed, worked a treat. baptiste auguie-5 wrote: > > Hi, > > I think this is a case where you should use the ?"[[" extraction > operator rather than "$", > > d = data.frame(a=1:3) > mytarget = "a" > d[[mytarget]] > > > HTH, > > baptiste > > 2009/10/11 tdm : >> >> Hi, >> >> I am passing a data frame and field name to a function. I've figured out >> how >> I can create the formula based on the passed in field name, but I'm >> struggling to create a vector based in that field. >> >> for example if I hard code with the actual field name >> >> Y = df$Target, everything works fine. >> >> but if I use the passed in parameter name, it doesn't give me what I >> want, >> >> Y = df$mytarget >> >> >> Here is the function, >> >> # trying to pass field name to a function >> logistictest <- function(df,mytarget) >> { >> >> #library for AUC calculation >> library(caTools) >> >> #build logistic model >> mytarget <- deparse(substitute(mytarget)) >> myformula <- paste(mytarget," ~ .") >> myformula <- deparse(substitute(myformula)) >> logistic_reg <- glm(myformula , data=df, family=binomial(link="logit")) >> print("model build OK") >> >> #score up >> scores <- predict(logistic_reg, type="response", df) >> print("model scored OK") >> >> #calc AUC >> Y = df$mytarget >> >> auc <- colAUC(scores,Y) >> print("auc calculated OK") >> >> } >> >> logistictest(df=trainset,mytarget=Target) >> >> >> [1] "model build OK" >> [1] "model scored OK" >> Error in as.vector(x, mode) : invalid 'mode' argument >> >> -- >> View this message in context: >> http://www.nabble.com/field-names-as-function-parameters-tp25838606p25838606.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> 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. > > -- View this message in context: http://www.nabble.com/field-names-as-function-parameters-tp25840951p25841450.html Sent from the R help mailing list archive at Nabble.com. __ 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] field names as function parameters
Hi, I am passing a data frame and field name to a function. I've figured out how I can create the formula based on the passed in field name, but I'm struggling to create a vector based in that field. for example if I hard code with the actual field name Y = df$Target, everything works fine. but if I use the passed in parameter name, it doesn't give me what I want, Y = df$mytarget Here is the function, # trying to pass field name to a function logistictest <- function(df,mytarget) { #library for AUC calculation library(caTools) #build logistic model mytarget <- deparse(substitute(mytarget)) myformula <- paste(mytarget," ~ .") myformula <- deparse(substitute(myformula)) logistic_reg <- glm(myformula , data=df, family=binomial(link="logit")) print("model build OK") #score up scores <- predict(logistic_reg, type="response", df) print("model scored OK") #calc AUC Y = df$mytarget auc <- colAUC(scores,Y) print("auc calculated OK") } logistictest(df=trainset,mytarget=Target) [1] "model build OK" [1] "model scored OK" Error in as.vector(x, mode) : invalid 'mode' argument -- View this message in context: http://www.nabble.com/field-names-as-function-parameters-tp25838606p25838606.html Sent from the R help mailing list archive at Nabble.com. __ 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] passing field name parameter to function
Hi, I am passing a data frame and field name to a function. I've figured out how I can create the formula based on the passed in field name, but I'm struggling to create a vector based in that field. for example if I hard code with the actual field name Y = df$Target, everything works fine. but if I use the passed in parameter name, it doesn't give me what I want, Y = df$mytarget Here is the function, # trying to pass field name to a function logistictest <- function(df,mytarget) { #library for AUC calculation library(caTools) #build logistic model mytarget <- deparse(substitute(mytarget)) myformula <- paste(mytarget," ~ .") myformula <- deparse(substitute(myformula)) logistic_reg <- glm(myformula , data=df, family=binomial(link="logit")) print("model build OK") #score up scores <- predict(logistic_reg, type="response", df) print("model scored OK") #calc AUC Y = df$mytarget auc <- colAUC(scores,Y) print("auc calculated OK") } logistictest(df=trainset,mytarget=Target) [1] "model build OK" [1] "model scored OK" Error in as.vector(x, mode) : invalid 'mode' argument -- View this message in context: http://www.nabble.com/passing-field-name-parameter-to-function-tp25840014p25840014.html Sent from the R help mailing list archive at Nabble.com. __ 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.