[R] (windows) opening document with particular exe file
Hello dear R, I dont have specific task on mind just learning R. 1) Is it possible to open a document for example path1\myfile.pdf with program path2\pdfviewer.exe ? How would I do it in win? Does it differ in linux? 2) Is it possible to run a program and supply to it some streams? The streams are for example txt file or web address. One specific task which comes to mid: I would like to draw in inkscape programmatically with script. Is it somehow possible? Thank you very much for any help in advance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] How to print the frequency table (produced by the command "table" to Excel
Hi jpm miao, You can get CSV files that can be imported into Excel like this: library(prettyR) sink("excel_table1.csv") delim.table(table(df[,c("y","z")])) sink() sink("excel_table2.csv") delim.table(as.data.frame(table(df[,c("y","z")])),label="") sink() sink("excel_table3.csv") delim.table(as.matrix(table(df[,c("y","z")])),label="") sink() Jim On Wed, Apr 27, 2016 at 8:35 AM, jpm miaowrote: > Hi, > >How could we print the frequency table (produced by "table") to an Excel > file? >Is there an easy way to do so? Thanks, > > Miao > >> df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3]) > >> table(df[,c("y","z")]) >z > y a b c > 1 0 0 1 > 2 0 1 0 > 3 1 0 0 >> test<-table(df[,c("y","z")]) >> as.data.frame(test) > y z Freq > 1 1 a0 > 2 2 a0 > 3 3 a1 > 4 1 b0 > 5 2 b1 > 6 3 b0 > 7 1 c1 > 8 2 c0 > 9 3 c0 >> as.matrix(test) >z > y a b c > 1 0 0 1 > 2 0 1 0 > 3 1 0 0 >> testm<-as.matrix(test) >> testm >z > y a b c > 1 0 0 1 > 2 0 1 0 > 3 1 0 0 >> typeof(testm) > [1] "integer" > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] How to print the frequency table (produced by the command "table" to Excel
Hi, How could we print the frequency table (produced by "table") to an Excel file? Is there an easy way to do so? Thanks, Miao > df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3]) > table(df[,c("y","z")]) z y a b c 1 0 0 1 2 0 1 0 3 1 0 0 > test<-table(df[,c("y","z")]) > as.data.frame(test) y z Freq 1 1 a0 2 2 a0 3 3 a1 4 1 b0 5 2 b1 6 3 b0 7 1 c1 8 2 c0 9 3 c0 > as.matrix(test) z y a b c 1 0 0 1 2 0 1 0 3 1 0 0 > testm<-as.matrix(test) > testm z y a b c 1 0 0 1 2 0 1 0 3 1 0 0 > typeof(testm) [1] "integer" [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Hi Bert: I thought in centering Baci variable, but I wouldn`t like to draw a conclusion based on the scaled response variable. On the other hand, if I had to center the explanatory variable, that would be great, but I cannot, as it is a factor. Thanks a lot for your time. I really appreciated your help. Best regards, Andre On Tue, Apr 26, 2016 at 4:11 PM, Bert Gunterwrote: > Inline. > > -- Bert > > > On Tue, Apr 26, 2016 at 2:25 PM, André Luis Neves > wrote: > > Ok. I`m trying to run a Poisson glmm with an observation-level random > > intercept. But I`m getting the following error for the 'Baci' variable: > > > > 'Error: (maxstephalfit) PIRLS step-halvings failed to reduce deviance in > > pwrssUpdate'. I guess this message is because the baci variable is not a > > an integer, > > Why would you "guess" that? Given your magnitudes, I suspect it's a > scaling issue. Try centering and scaling your Baci variable before > fitting. > > Cheers, > Bert > > > > > > and cannot be transformed into an integer as R has a threshold > > of > > 2x10^9 even in 64 bit R. > > > > It runs fine for the fungii variable. > > > > If you guys want to run the data (attached), the full command is below. > > > > Thanks. > > > > - > > > > ##Import data: > > > > qPCR <- read.delim(file.choose(), > > header = TRUE, > > dec = ".") > > > > ##Load package > > > > library(lme4) > > > > ##Other steps: > > > > qPCR$obs <- 1:nrow(qPCR) > > qPCR$fID<-as.factor(qPCR$ID) > > qPCR$fDiet<-as.factor(qPCR$Diet) > > > > ##Run the model: > > > > M1 <- glmer (Baci ~ fDiet + Crossover + (1|fID:Crossover) + (1|obs), > > family = poisson, data=qPCR) > > > > > > > > Andre > > > > > > > > On Tue, Apr 26, 2016 at 2:36 PM, jim holtman wrote: > > > >> Can you explain why you need them as 'integer', A floating point > >> representation can hold a value upto ~4.5e15 as an "integer" keeping the > >> precision that you might need. > >> > >> > >> Jim Holtman > >> Data Munger Guru > >> > >> What is the problem that you are trying to solve? > >> Tell me what you want to do, not how you want to do it. > >> > >> On Tue, Apr 26, 2016 at 1:11 PM, André Luis Neves > > >> wrote: > >> > >>> Dear all: > >>> > >>> I converted the columns (Baci, Meti, Fungii, Protozoai) into integers > >>> (using excel) and then imported the data (.txt) into R. Interestingly, > the > >>> other three variables were loaded as INT, but the 'Baci' one continued > as > >>> Num. > >>> > >>> I imported the data using the following command line: > >>> > >>> X <- read.delim(file.choose(), > >>> header = TRUE, > >>> dec = ".") > >>> > >>> Here is the structure of X: > >>> > >>> > str(X) > >>> 'data.frame': 115 obs. of 5 variables: > >>> $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 > 26 27 > >>> 29 31 32 36 ... > >>> $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... > >>> $ Meti : int 352645997 334146268 767208656 171567266 462747405 > >>> 414905627 237010514 387480048 214671355 328813226 ... > >>> $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 > 13746 > >>> ... > >>> $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 > >>> 203685 > >>> 4261780 43110492 69802572 ... > >>> > >>> > >>> I need Baci as an integer, and tried to convert it using as.integer > >>> function, but was not successful. > >>> > >>> > >>> Could anyone please help me to solve this problem. > >>> > >>> Thanks, > >>> > >>> > >>> > >>> -- > >>> Andre > >>> > >>> __ > >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >>> 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. > >>> > >> > >> > > > > > > -- > > Andre > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > -- Andre [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Inline. -- Bert On Tue, Apr 26, 2016 at 2:25 PM, André Luis Neveswrote: > Ok. I`m trying to run a Poisson glmm with an observation-level random > intercept. But I`m getting the following error for the 'Baci' variable: > > 'Error: (maxstephalfit) PIRLS step-halvings failed to reduce deviance in > pwrssUpdate'. I guess this message is because the baci variable is not a > an integer, Why would you "guess" that? Given your magnitudes, I suspect it's a scaling issue. Try centering and scaling your Baci variable before fitting. Cheers, Bert and cannot be transformed into an integer as R has a threshold > of > 2x10^9 even in 64 bit R. > > It runs fine for the fungii variable. > > If you guys want to run the data (attached), the full command is below. > > Thanks. > > - > > ##Import data: > > qPCR <- read.delim(file.choose(), > header = TRUE, > dec = ".") > > ##Load package > > library(lme4) > > ##Other steps: > > qPCR$obs <- 1:nrow(qPCR) > qPCR$fID<-as.factor(qPCR$ID) > qPCR$fDiet<-as.factor(qPCR$Diet) > > ##Run the model: > > M1 <- glmer (Baci ~ fDiet + Crossover + (1|fID:Crossover) + (1|obs), > family = poisson, data=qPCR) > > > > Andre > > > > On Tue, Apr 26, 2016 at 2:36 PM, jim holtman wrote: > >> Can you explain why you need them as 'integer', A floating point >> representation can hold a value upto ~4.5e15 as an "integer" keeping the >> precision that you might need. >> >> >> Jim Holtman >> Data Munger Guru >> >> What is the problem that you are trying to solve? >> Tell me what you want to do, not how you want to do it. >> >> On Tue, Apr 26, 2016 at 1:11 PM, André Luis Neves >> wrote: >> >>> Dear all: >>> >>> I converted the columns (Baci, Meti, Fungii, Protozoai) into integers >>> (using excel) and then imported the data (.txt) into R. Interestingly, the >>> other three variables were loaded as INT, but the 'Baci' one continued as >>> Num. >>> >>> I imported the data using the following command line: >>> >>> X <- read.delim(file.choose(), >>> header = TRUE, >>> dec = ".") >>> >>> Here is the structure of X: >>> >>> > str(X) >>> 'data.frame': 115 obs. of 5 variables: >>> $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27 >>> 29 31 32 36 ... >>> $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... >>> $ Meti : int 352645997 334146268 767208656 171567266 462747405 >>> 414905627 237010514 387480048 214671355 328813226 ... >>> $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 13746 >>> ... >>> $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 >>> 203685 >>> 4261780 43110492 69802572 ... >>> >>> >>> I need Baci as an integer, and tried to convert it using as.integer >>> function, but was not successful. >>> >>> >>> Could anyone please help me to solve this problem. >>> >>> Thanks, >>> >>> >>> >>> -- >>> Andre >>> >>> __ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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. >>> >> >> > > > -- > Andre > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] table , exclude - count the frequency in a data frame but exclude one value
table converts its non-factor arguments to factors using the exclude argument that you supply. If you want the arguments to be handled differently, then convert them to factors yourself, in the way you want. E.g., > with(df, table(x=factor(x, exclude=1), y)) y x 1 2 3 2 0 1 0 3 1 0 0 > with(df, table(x=factor(x, exclude=1), y=factor(y, levels=3:1))) y x 3 2 1 2 0 1 0 3 0 0 1 Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Apr 26, 2016 at 2:21 PM, jpm miaowrote: > Hi, > >I have a data frame with two variables x, y, both of which take values > in the set {1,2,3}. I'd like to count the frequency by the command "table", > but exclude the value "1" in variable x, but keep "1" in variable y. Is it > possible? When I use "exclude", value 1 in both x and y are excluded. > Thanks, > > > > df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3]) > > table(df[,c("y","x")]) >x > y 1 2 3 > 1 0 0 1 > 2 0 1 0 > 3 1 0 0 > > table(df[,c("y","x")], exclude = 1) >x > y 2 3 > 2 1 0 > 3 0 0 > > table(df[,c("y","x")], exclude = c(NULL, 1)) >x > y 2 3 > 2 1 0 > 3 0 0 > > table(df[,c("y","x")], exclude = c(1, NULL)) >x > y 2 3 > 2 1 0 > 3 0 0 > > table(df[,c("y","x")], exclude = c(1, 0)) >x > y 2 3 > 2 1 0 > 3 0 0 > > table(df[,c("y","x")], exclude = list(1 , NULL)) > Error in as.vector(exclude, typeof(x)) : > (list) object cannot be coerced to type 'integer' > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Ok. I`m trying to run a Poisson glmm with an observation-level random intercept. But I`m getting the following error for the 'Baci' variable: 'Error: (maxstephalfit) PIRLS step-halvings failed to reduce deviance in pwrssUpdate'. I guess this message is because the baci variable is not a an integer, and cannot be transformed into an integer as R has a threshold of 2x10^9 even in 64 bit R. It runs fine for the fungii variable. If you guys want to run the data (attached), the full command is below. Thanks. - ##Import data: qPCR <- read.delim(file.choose(), header = TRUE, dec = ".") ##Load package library(lme4) ##Other steps: qPCR$obs <- 1:nrow(qPCR) qPCR$fID<-as.factor(qPCR$ID) qPCR$fDiet<-as.factor(qPCR$Diet) ##Run the model: M1 <- glmer (Baci ~ fDiet + Crossover + (1|fID:Crossover) + (1|obs), family = poisson, data=qPCR) Andre On Tue, Apr 26, 2016 at 2:36 PM, jim holtmanwrote: > Can you explain why you need them as 'integer', A floating point > representation can hold a value upto ~4.5e15 as an "integer" keeping the > precision that you might need. > > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > On Tue, Apr 26, 2016 at 1:11 PM, André Luis Neves > wrote: > >> Dear all: >> >> I converted the columns (Baci, Meti, Fungii, Protozoai) into integers >> (using excel) and then imported the data (.txt) into R. Interestingly, the >> other three variables were loaded as INT, but the 'Baci' one continued as >> Num. >> >> I imported the data using the following command line: >> >> X <- read.delim(file.choose(), >> header = TRUE, >> dec = ".") >> >> Here is the structure of X: >> >> > str(X) >> 'data.frame': 115 obs. of 5 variables: >> $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27 >> 29 31 32 36 ... >> $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... >> $ Meti : int 352645997 334146268 767208656 171567266 462747405 >> 414905627 237010514 387480048 214671355 328813226 ... >> $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 13746 >> ... >> $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 >> 203685 >> 4261780 43110492 69802572 ... >> >> >> I need Baci as an integer, and tried to convert it using as.integer >> function, but was not successful. >> >> >> Could anyone please help me to solve this problem. >> >> Thanks, >> >> >> >> -- >> Andre >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > > -- Andre ID Crossover Period DietPen TimeBaciFungii fNDF Starch 126BLK 1 1 Forage 1 End12.90E+1243645 3.87056104 1.443771827 13ZBLK 1 1 Forage 1 End15.55E+1119009 3.970286296 1.480970702 157BLK 1 1 Forage 1 End19.46E+1115998 4.114130366 1.534626493 162ZRED 1 1 Forage 1 End18.13E+112189 3.600760128 1.343132423 17ZBLKY 1 1 Forage 1 End14.06E+118972 3.79087129 1.414046468 184ZBLK 1 1 Forage 1 End15.75E+118240 3.815881751 1.42337571 1ZBLKW 1 1 Forage 1 End134490836164 3133 3.295433507 1.229241447 2094ZBLK1 1 Forage 1 End13.49E+1117922 3.737865394 1.394274549 20LZBLK 1 1 Forage 1 End11.63E+116156 4.007824601 1.494972999 29ZBLK 1 1 Forage 1 End13.37E+1113746 3.59031272 1.339235398 2ZBLKG 1 1 Forage 1 End13.13E+114003 3.964994752 1.478996884 60ZRED 1 1 Forage 1 End13.76E+1112473 3.477652579 1.297211636 77BLK 1 1 Forage 1 End12.92E+1113328 4.546906317 1.696057799 8ZBLK 1 1 Forage 1 End12.45E+112900 4.447927304 1.659137284 91ZRED 1 1 Forage 1 End15.62E+118584 4.118042491 1.536085769 112BLKW 2 1 Forage 2 End170249927920 192654 4.024558544 1.501214987 1226BLK 2 1 Forage 2 End118390770816 65524 3.933087193 1.467094931 12ZBLK 2 1 Forage 2 End164465242768 286966 3.678844325 1.372258889 134BLK 2 1 Forage 2 End19652868358 47474 3.902242465
[R] table , exclude - count the frequency in a data frame but exclude one value
Hi, I have a data frame with two variables x, y, both of which take values in the set {1,2,3}. I'd like to count the frequency by the command "table", but exclude the value "1" in variable x, but keep "1" in variable y. Is it possible? When I use "exclude", value 1 in both x and y are excluded. Thanks, > df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3]) > table(df[,c("y","x")]) x y 1 2 3 1 0 0 1 2 0 1 0 3 1 0 0 > table(df[,c("y","x")], exclude = 1) x y 2 3 2 1 0 3 0 0 > table(df[,c("y","x")], exclude = c(NULL, 1)) x y 2 3 2 1 0 3 0 0 > table(df[,c("y","x")], exclude = c(1, NULL)) x y 2 3 2 1 0 3 0 0 > table(df[,c("y","x")], exclude = c(1, 0)) x y 2 3 2 1 0 3 0 0 > table(df[,c("y","x")], exclude = list(1 , NULL)) Error in as.vector(exclude, typeof(x)) : (list) object cannot be coerced to type 'integer' [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Predicting probabilities in ordinal probit analysis in R
Dear all, I have two questions that are almost completely related to how to do things in R. I am running an ordinal probit regression analysis in R. The dependent variable has three levels (0=no action; 1=warning; 2=sanction). I use the lrm command in the rms package: print( res1<- lrm(Y ~ x1+x2+x3+x4+x5+x6, y=TRUE, x=TRUE, data=mydata)) I simply couldn't make any sense of the information generated my ?predict.lrm. What I want to do is to calculate the marginal effects of all explanatory variables for each level of the dependent variable. In Stata, this is very simple: mfx compute, predict (outcome(#0)); mfx compute, predict (outcome(#2)) and mfx compute, predict (outcome(#3)). So my first question is: how do I generate marginal effects for each outcome in R? The second question is related to interaction effects, which I need to include in the same model: print( res1<- lrm(Y ~ x1+x2+x3+x4+x5+x6+x5*x6, y=TRUE, x=TRUE, data=mydata)) If I knew the answer to the first question, I would have ran marginal effects with the interaction term included. Then, I would have plotted the predicted values of the interaction term. So the second question is: how do I plot the effects (predicted values) of variables in the interaction term? Many thanks! Small sample from my dataset (only one country) dput(mydatasample) structure(list(year = 1989:2014, country = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "Canada", class = "factor"), id = structure(1:26, .Label = c("CAN 1989", "CAN 1990", "CAN 1991", "CAN 1992", "CAN 1993", "CAN 1994", "CAN 1995", "CAN 1996", "CAN 1997", "CAN 1998", "CAN 1999", "CAN 2000", "CAN 2001", "CAN 2002", "CAN 2003", "CAN 2004", "CAN 2005", "CAN 2006", "CAN 2007", "CAN 2008", "CAN 2009", "CAN 2010", "CAN 2011", "CAN 2012", "CAN 2013", "CAN 2014"), class = "factor"), stage1 = c(1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), x1 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L), x2 = c(1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L), x3 = c(9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 8L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L), x4 = c(31L, 31L, 31L, 31L, 31L, 30L, 30L, 30L, 31L, 30L, 29L, 30L, 28L, 28L, 28L, 27L, 29L, 29L, 29L, 28L, 25L, 24L, 23L, NA, NA, NA), x5 = structure(1:26, .Label = c("17,12528685", "17,14022279", "17,15382785", "17,16610202", "17,17704534", "17,18665779", "17,19493938", "17,20571103", "17,21628118", "17,22493732", "17,23321101", "17,242041", "17,25213621", "17,26110753", "17,27106985", "17,2810902", "17,29094924", "17,29891768", "17,30861622", "17,31943819", "17,33088659", "17,34202619", "17,35190237", "17,36381421", "17,37537139", "17,38618117"), class = "factor"), x5.1 = c(0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L)), .Names = c("year", "country", "id", "stage1", "x1", "x2", "x3", "x4", "x5", "x5.1"), class = "data.frame", row.names = c(NA, -26L)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Can you explain why you need them as 'integer', A floating point representation can hold a value upto ~4.5e15 as an "integer" keeping the precision that you might need. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Tue, Apr 26, 2016 at 1:11 PM, André Luis Neveswrote: > Dear all: > > I converted the columns (Baci, Meti, Fungii, Protozoai) into integers > (using excel) and then imported the data (.txt) into R. Interestingly, the > other three variables were loaded as INT, but the 'Baci' one continued as > Num. > > I imported the data using the following command line: > > X <- read.delim(file.choose(), > header = TRUE, > dec = ".") > > Here is the structure of X: > > > str(X) > 'data.frame': 115 obs. of 5 variables: > $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27 > 29 31 32 36 ... > $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... > $ Meti : int 352645997 334146268 767208656 171567266 462747405 > 414905627 237010514 387480048 214671355 328813226 ... > $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 13746 > ... > $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 203685 > 4261780 43110492 69802572 ... > > > I need Baci as an integer, and tried to convert it using as.integer > function, but was not successful. > > > Could anyone please help me to solve this problem. > > Thanks, > > > > -- > Andre > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] vectors of equations in ode / desolve
Hello, I have a syntactic problem with ode. How do I specify vectors of equations in ordinary differential equation systems. (i.e. in my case I want to simulate an a priory undefined number of species that have different parameters but the same behaviour) I demonstrate this using the Lotka Volterra example. The code below does not work and I have not a good idea how to specify this right. ## === ## Example1: Predator-Prey Lotka-Volterra model (with logistic prey) ## === LVmod <- function(Time, State, Pars) { with(as.list(c(State, Pars)), { # Now there are different species of Prey so Prey is a one dimensional vector, #Ingestion is also a one-dimensional vector. The number of species is not defined a priory Ingestion<- rIng * Prey * Predator GrowthPrey <- rGrow * Prey * (1 - Prey/K) MortPredator <- rMort * Predator dPrey<- GrowthPrey - Ingestion # thegrowth of predator would depend on the ingestion of all prays regardless of species sumIngestion<-sum(Ingestion) dPredator<- sumIngestion * assEff - MortPredator # returning an array of preys does produce an error return(list(c(dPrey, dPredator))) }) } # Example is made for three different species of prey pars <- c(rIng = 0.2,# /day, rate of ingestion # I do not know how to pass on these parameters as a vector this productes and error rGrow = c(1.0, 1.3, 1.7)# /day, growth rate of prey rMort = 0.2 , # /day, mortality rate of predator assEff = 0.5,# -, assimilation efficiency K = 10) # mmol/m3, carrying capacity yini <- c(Prey = c(1, 2,3), Predator = 2) times <- seq(0, 200, by = 1) out <- ode(yini, times, LVmod, pars) summary(out) Thanks Frank __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Linear Regressions with constraint coefficients
Any help with exporting anova output in R to csv or xlsx? From: "Aleksandrovic, Aljosa (Pfaeffikon)"To: Bert Gunter Cc: "r-help@r-project.org" Sent: Tuesday, April 26, 2016 8:29 AM Subject: Re: [R] Linear Regressions with constraint coefficients Ok, and if I would just like to force my slope coefficients to be inside an interval, let's say, between 0 and 1? Is there a way in R to formulate such a constraint regression? Thanks in advance and kind regards, Aljosa Aljosa Aleksandrovic, FRM, CAIA Quantitative Analyst - Convertibles aljosa.aleksandro...@man.com Tel +41 55 417 7603 Man Investments (CH) AG Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland -Original Message- From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Dienstag, 26. April 2016 16:51 To: Aleksandrovic, Aljosa (Pfaeffikon) Cc: r-help@r-project.org Subject: Re: [R] Linear Regressions with constraint coefficients If the slope coefficients sum to a constant, the regressors are dependent and so a unique solution is impossible (an infinity of solutions would result). So I think you have something going on that you don't understand and should consult a local statistician to help you formulate your problem appropriately. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 5:39 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:35 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Subject: Re: Linear Regressions with constraint coefficients > > You need to send it to r-help@r-project.org however. > > Kevin > > On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Ok, will do! Thx a lot! >> >> Please find below my request: >> >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:28 >> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >> Subject: Re: Linear Regressions with constraint coefficients >> >> I believe I approved a message with such a subject. Perhaps there was >> another layer that subsequently rejected it after that. I didn't notice any >> unusual content. Try again, making sure you send the message in plain text >> only. >> >> Kevin >> >> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Do you know where I get help for my issue? >>> >>> Thanks in advance and kind regards, >>> Aljosa >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >>> r-help-ow...@r-project.org >>> Sent: Dienstag, 26. April 2016 14:10 >>> To: Aleksandrovic, Aljosa (Pfaeffikon) >>>
[R] survival::clogit, how to extract residuals for GOF assessment
Hi Folks, Hopefully this question has enough R and not too much stats to be appropriate for this list. Based on,* Hosmer et al. 2013. Logistic regression for matched case-control studies. Applied Logistic Regression *(eqtn. 7.8)*, *I am assessing GOF of conditional (or matched) logistic regression models with the *standardized Pearson residuals*. The authors define “large” as delta chi-squared values > 4. For a 1:1 study, I can fit a conditional logistic model via an unconditional routine by making the response variable all 1’s, taking the difference of the covariate values for each pair, and removing the intercept. I can then extract the standardized residuals from the model (see code at bottom for example). However, if I want to fit a 1:many model, I need to use survival::clogit, which is where my question comes in: How can I apply this same "test" to a clogit model? Which residuals should I be extracting? Or, is this not an option for a clogit model? ## The default residuals of coxph in R are the martingale residuals. ## resid(fit1,type=c("martingale", "deviance", "score", "schoenfeld", ## "dfbeta", "dfbetas", "scaledsch","partial")) R code below shows equivalence between clogit and binomial GLM fit on the differences (note: these would not be equivalent if used a "cluster" argument in clogit), and GOF "test" for binomial GLM fit on the differences. I would like to assess GOF of the fit.clogit model but do not know how. require(survival) require(plyr) # Dataframe dat.full <- structure(list(resp = c(1L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L), x1 = c(3.92, 2.04, 2.27, 9.25, 6.13, 10.44, 5.09, 1.27, 5.9, 2.88, 3.79, 1.46, 3.35, 3.82, 4.28, 6.52, 3.54, 3.46, 0.46, 1.68, 3.22, 1.64, -0.12, 2.78, 2.58, 2, 2.83, 3.58, 1.45, 1.64, 2.89, 3.12, 5.6, 8.29, 3.42, 4.8, 3.04, 4.33, 5.31, 1.78, 8.18, 4.56, 4.85, 7.99, 7.52, 6.85, 7.64, 3.33, 5.17, 4.62, 1.24, 2.54, 3.08, 8.2, 1.81, 2.78, 2.16, 2.76, 3.45, 3.43), ID = c(10L, 10L, 11L, 11L, 13L, 13L, 17L, 17L, 18L, 18L, 23L, 23L, 25L, 25L, 29L, 29L, 31L, 31L, 33L, 33L, 35L, 35L, 38L, 38L, 39L, 39L, 4L, 4L, 41L, 41L, 43L, 43L, 45L, 45L, 46L, 46L, 49L, 49L, 50L, 50L, 54L, 54L, 55L, 55L, 56L, 56L, 57L, 57L, 59L, 59L, 6L, 6L, 60L, 60L, 7L, 7L, 8L, 8L, 9L, 9L)), .Names = c("resp", "x1", "ID"), row.names = c(1L, 2L, 3L, 4L, 7L, 8L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 21L, 22L, 23L, 24L, 25L, 26L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 49L, 50L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 71L, 72L, 73L, 74L, 75L, 76L), class = "data.frame") # fit clogit fit.clogit <- clogit(resp ~ x1 + strata(ID), method = "efron", data = dat.full) summary(fit.clogit) # Make dataframe so can fit on differences with unconditional routine. # x1 where resp = 1 minus x1 where resp = 0, grouped by ID dat.diff <- ddply(dat.full, .(ID), summarise, x1.diff = x1[resp == 1] - x1[resp == 0]) dat.diff$resp <- 1 # response variable is all 1's # Fit on differences and 1's, remove intercept fit.diff <- glm(resp ~ -1 + x1.diff, family = binomial, data = dat.diff) summary(fit.diff) summary(fit.clogit)$coefficients # GOF: delta chi-squared plot(fit.diff$fitted.values, rstandard(fit.diff)^2) round(sort(rstandard(fit.diff)^2), 4) Thanks! Joe [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Please respond to the list. It will be obvious why in a second. That's not my threshhold! -- it's R's. Your numeric integers cannot be exactly represented as integers in R. Period. Maybe there are special packages for extended arithmetic that can do this. but someone else would have to help you there. See here for a discussion that might be helpful: http://www.r-bloggers.com/r-in-a-64-bit-world/ Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 10:46 AM, André Luis Neveswrote: > So, How could I implement this, Bert? > > I really need that the variable be converted unto an integer, and it seems > that my numbers are much higher than that threshold you stated. > > Thanks, > > Andre > > On Tue, Apr 26, 2016 at 11:42 AM, Bert Gunter > wrote: >> >> No. >> >> From ?as.integer: >> >> "Note that current implementations of R use 32-bit integers for >> integer vectors, so the range of representable integers is restricted >> to about +/-2*10^9: doubles can hold much larger integers exactly. " >> >> Cheers, >> Bert >> >> >> Bert Gunter >> >> "The trouble with having an open mind is that people keep coming along >> and sticking things into it." >> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) >> >> >> On Tue, Apr 26, 2016 at 10:11 AM, André Luis Neves >> wrote: >> > Dear all: >> > >> > I converted the columns (Baci, Meti, Fungii, Protozoai) into integers >> > (using excel) and then imported the data (.txt) into R. Interestingly, >> > the >> > other three variables were loaded as INT, but the 'Baci' one continued >> > as >> > Num. >> > >> > I imported the data using the following command line: >> > >> > X <- read.delim(file.choose(), >> > header = TRUE, >> > dec = ".") >> > >> > Here is the structure of X: >> > >> >> str(X) >> > 'data.frame': 115 obs. of 5 variables: >> > $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 >> > 27 >> > 29 31 32 36 ... >> > $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... >> > $ Meti : int 352645997 334146268 767208656 171567266 462747405 >> > 414905627 237010514 387480048 214671355 328813226 ... >> > $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 >> > 13746 >> > ... >> > $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 >> > 203685 >> > 4261780 43110492 69802572 ... >> > >> > >> > I need Baci as an integer, and tried to convert it using as.integer >> > function, but was not successful. >> > >> > >> > Could anyone please help me to solve this problem. >> > >> > Thanks, >> > >> > >> > >> > -- >> > Andre >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > 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. > > > > > -- > Andre __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] From NUM to INT
That is the "impossible" case, since R integers are 32 bit signed (~2×10^9) even in 64 bit R. You can Google for "R arbitrary precision" and look for packages like Ryacas, bit64 or gmp. However, having such large integers stored as integers would not be necessary for most statistical analyses so you should confirm that your analysis cannot be performed using floating point numbers before resorting to that. -- Sent from my phone. Please excuse my brevity. On April 26, 2016 10:11:38 AM PDT, "André Luis Neves"wrote: >Dear all: > >I converted the columns (Baci, Meti, Fungii, Protozoai) into integers >(using excel) and then imported the data (.txt) into R. Interestingly, >the >other three variables were loaded as INT, but the 'Baci' one continued >as >Num. > >I imported the data using the following command line: > >X <- read.delim(file.choose(), > header = TRUE, > dec = ".") > >Here is the structure of X: > >> str(X) >'data.frame': 115 obs. of 5 variables: >$ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 >27 >29 31 32 36 ... > $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... > $ Meti : int 352645997 334146268 767208656 171567266 462747405 >414905627 237010514 387480048 214671355 328813226 ... >$ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 >13746 >... >$ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 >203685 >4261780 43110492 69802572 ... > > >I need Baci as an integer, and tried to convert it using as.integer >function, but was not successful. > > >Could anyone please help me to solve this problem. > >Thanks, > > > >-- >Andre > > > > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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 -- To UNSUBSCRIBE and more, see 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] From NUM to INT
No. >From ?as.integer: "Note that current implementations of R use 32-bit integers for integer vectors, so the range of representable integers is restricted to about +/-2*10^9: doubles can hold much larger integers exactly. " Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 10:11 AM, André Luis Neveswrote: > Dear all: > > I converted the columns (Baci, Meti, Fungii, Protozoai) into integers > (using excel) and then imported the data (.txt) into R. Interestingly, the > other three variables were loaded as INT, but the 'Baci' one continued as > Num. > > I imported the data using the following command line: > > X <- read.delim(file.choose(), > header = TRUE, > dec = ".") > > Here is the structure of X: > >> str(X) > 'data.frame': 115 obs. of 5 variables: > $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27 > 29 31 32 36 ... > $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... > $ Meti : int 352645997 334146268 767208656 171567266 462747405 > 414905627 237010514 387480048 214671355 328813226 ... > $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 13746 > ... > $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 203685 > 4261780 43110492 69802572 ... > > > I need Baci as an integer, and tried to convert it using as.integer > function, but was not successful. > > > Could anyone please help me to solve this problem. > > Thanks, > > > > -- > Andre > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] From NUM to INT
Dear all: I converted the columns (Baci, Meti, Fungii, Protozoai) into integers (using excel) and then imported the data (.txt) into R. Interestingly, the other three variables were loaded as INT, but the 'Baci' one continued as Num. I imported the data using the following command line: X <- read.delim(file.choose(), header = TRUE, dec = ".") Here is the structure of X: > str(X) 'data.frame': 115 obs. of 5 variables: $ ID : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27 29 31 32 36 ... $ Baci : num 2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ... $ Meti : int 352645997 334146268 767208656 171567266 462747405 414905627 237010514 387480048 214671355 328813226 ... $ Fungii : int 43645 19009 15998 2189 8972 8240 3133 17922 6156 13746 ... $ Protozoai: int 3220523 1851891 3252462 1665675 34123768 23175015 203685 4261780 43110492 69802572 ... I need Baci as an integer, and tried to convert it using as.integer function, but was not successful. Could anyone please help me to solve this problem. Thanks, -- Andre ID BaciMetiFungii Protozoai 126BLK 2.90E+12352645997 43645 3220523 13ZBLK 5.55E+11334146268 19009 1851891 157BLK 9.46E+11767208656 15998 3252462 162ZRED 8.13E+11171567266 21891665675 17ZBLKY 4.06E+11462747405 897234123768 184ZBLK 5.75E+11414905627 824023175015 1ZBLKW 3.45E+10237010514 3133203685 2094ZBLK3.49E+11387480048 17922 4261780 20LZBLK 1.63E+11214671355 615643110492 29ZBLK 3.37E+11328813226 13746 69802572 2ZBLKG 3.13E+11564519908 400393195958 60ZRED 3.76E+11145383281 12473 33141411 77BLK 2.92E+11227643897 13328 306363850 8ZBLK 2.45E+11565298547 290029939862 91ZRED 5.62E+11472996887 858473402283 112BLKW 7.02E+10475554339 192654 37844605 1226BLK 1.84E+10239034620 65524 3994847 12ZBLK 6.45E+10296646742 286966 45244390 134BLK 9.65E+09201168840 47474 2756770 160ZRED 5.96E+10193983600 155040 79660710 166ZRED 8.14E+10315417009 26056 85856558 17ZBLK G1.88E+11626249880 74214 17763633 226ZBLK 3.88E+10181768548 291862 128256576 3ZBLK 2.38E+10175939117 46015 8351259 58BLK 5.37E+10304530782 50342 7718372 60ZBLK 4.23E+10375725507 146473 58960339 72ZRED 9.58E+10373650117 73205 171268872 7ZBLK 4.78E+10146490232 17068 171268872 95BLK 4.18E+10210377292 71368 31213851 9PZRED 7.12E+10278312630 178204 392574732 107ZRED 1.18E+11497812799 70745212968 129BLK 1.01E+10172557004 565 373103 150ZRED 1.48E+11343107486 786965118676 168BLK 9.45E+10298332033 528117428719 174ZBLK 6.29E+10269735103 24635 42532632 185ZRED 7.81E+10647775276 197348855746 2ZBLKY 4.93E+0935698451318328935576 4089ZBLK1.94E+10326852779 1329520051 438XZRED7.20E+09113153909 630 127811 4ZBLK 5.30E+10248877230 1469827989 706ZBLK 3.12E+10151072339 24074885127 86BLK 9.39E+10526984044 417 1034021 86ZRED 5.71E+10385701592 783492440481 89BLK 3.80E+10297806285 631462159379 112XZBLKG 9.56E+11603355806 5205199868382 1191ZBLK4.59E+11403738704 35115 93137246 122ZRED 2.93E+11266699375 930 68471595 14ZBLK 8.03E+11607043335 557075196835 15ZBLK 3.99E+11185346266 171626429018 163BLK 7.18E+11598193580 20475 419543828 175ZRED 2.08E+11660223375 442135481033 1ZBLKY 6.84E+11472986697 43059 137129730 20SXZBLK3.16E+112611953820297 8031502 22ZBLK 7.70E+11823508297 154975 264859084 63ZBLK 2.10E+111601226529 13317 44878482 6ZBLK 1.31E+11110772471 139540830068 82ZBLK 1.10E+12839550736 536868087375 92ZBLK 4.32E+11829679134 14981 98201518 94BLK 1.54E+11197873442 16806800437 126BLK 2.22E+11209765315 13000 92754991 13ZBLK 6.75E+11366018180 18291 60965929 157BLK 2.88E+11227660122 890420595699 162ZRED 1.85E+11372912115 3124516219 17ZBLKY 1.02E+11170028711 42881391174 184ZBLK 4.28E+11385951078 18173 142041693 1ZBLKW 1.26E+11258658827 39741096335 2094ZBLK2.80E+11299019239
Re: [R] Issue while building xtable on R on Ubuntu 15.04
> On Apr 26, 2016, at 4:08 AM, Zaid Golwalawrote: > > Please help in the below mentioned issue. > > Regards > Zaid Golwala > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Zaid Golwala > Sent: Wednesday, April 06, 2016 1:35 PM > To: r-help@R-project.org > Subject: [R] Issue while building xtable on R on Ubuntu 15.04 > > Hi, > > I am trying to build xtable on R on Ubuntu 15.04 but I get following error : > > > + R CMD check --no-vignettes --timings xtable_1.8-2.tar.gz > > * using log directory > '/home/jenkins/workspace/Rlang_xtable_Ubuntu15.04/xtable.Rcheck' > > * using R version 3.2.3 (2015-12-10) > > * using platform: powerpc64le-unknown-linux-gnu (64-bit) > > * using session charset: UTF-8 > > * using option '--no-vignettes > > '* checking for file 'xtable/DESCRIPTION' ... OK > > * this is package 'xtable' version '1.8-2' > > * checking package namespace information ... OK > > * checking package dependencies ...Error in .build_vignette_index(vigns) : > In 'inst' vignettes 'xtableGallery.Rnw' and 'xtableGallery.snw' have the same > vignette name Why not change one of the names? -- David. > > Can someone please help me regarding the same. > > Regards > Zaid Golwala > > DISCLAIMER\ ==\ This e-mail ...{{dropped:18}} > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Linear Regressions with constraint coefficients
Hi Gabor, Thanks a lot for your input! Kind regards, Aljosa Aljosa Aleksandrovic, FRM, CAIA Quantitative Analyst - Convertibles aljosa.aleksandro...@man.com Tel +41 55 417 76 03 Man Investments (CH) AG Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Dienstag, 26. April 2016 17:59 To: Aleksandrovic, Aljosa (Pfaeffikon) Cc: r-help@r-project.org Subject: Re: [R] Linear Regressions with constraint coefficients This is a quadratic programming problem that you can solve using either a quadratic programming solver with constraints or a general nonlinear solver with constraints. See https://cran.r-project.org/web/views/Optimization.html for more info on what is available. Here is an example using a nonlinear least squares solver and non-negative bound constraints. The constraint that the coefficients sum to 1 is implied by dividing them by their sum and then dividing the coefficients found by their sum at the end: # test data set.seed(123) n <- 1000 X1 <- rnorm(n) X2 <- rnorm(n) X3 <- rnorm(n) Y <- .2 * X1 + .3 * X2 + .5 * X3 + rnorm(n) # fit library(nlmrt) fm <- nlxb(Y ~ (b1 * X1 + b2 * X2 + b3 * X3)/(b1 + b2 + b3), data = list(Y = Y, X1 = X1, X2 = X2, X3 = X3), lower = numeric(3), start = list(b1 = 1, b2 = 2, b3 = 3)) giving the following non-negative coefficients which sum to 1 that are reasonably close to the true values of 0.2, 0.3 and 0.5: > fm$coefficients / sum(fm$coefficients) b1 b2 b3 0.18463 0.27887 0.53650 On Tue, Apr 26, 2016 at 8:39 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:35 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Subject: Re: Linear Regressions with constraint coefficients > > You need to send it to r-help@r-project.org however. > > Kevin > > On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Ok, will do! Thx a lot! >> >> Please find below my request: >> >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:28 >> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >> Subject: Re: Linear Regressions with constraint coefficients >> >> I believe I approved a message with such a subject. Perhaps there was >> another layer that subsequently rejected it after that. I didn't notice any >> unusual content. Try again, making sure you send the message in plain text >> only. >> >> Kevin >> >> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Do you know where I get help for my issue? >>> >>> Thanks in advance and kind regards, >>> Aljosa >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >>> r-help-ow...@r-project.org >>> Sent: Dienstag, 26. April
Re: [R] ylim in barplot()
Dear useRs, It seems that my last e-mail went quite unnoticed... Has anyone an idea about ylim doesn't work in barplot (see details below)? Thank you in advance, Ivan (on behalf of Stéphanie) -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.fr -- https://www.researchgate.net/profile/Ivan_Calandra https://publons.com/author/705639/ Le 26/04/2016 à 08:41, Ivan Calandra a écrit : Thank you David, That's a nice workaround using plotrix::barp(), but that doesn't explain why ylim doesn't work as intended (or at least, as I expect it to work), or why xpd has no influence when using devEMF::emf()... The problem with saving directly in RStudio is that it requires to manually save the plot, and this becomes troublesome when there are a lot of plot commands in a single script. Bests, Ivan (on behalf of Stéphanie) -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.fr -- https://www.researchgate.net/profile/Ivan_Calandra https://publons.com/author/705639/ Le 25/04/2016 21:16, David L Carlson a écrit : If you are using a Windows system, you can Export the plot from RStudio and save it as a metafile without using package devEMF and it will crop the bars with xpd=FALSE. When I used devEMF on a Windows machine, the bars were not cropped with barplot() as you indicated, but when I switched to plotrix::barp() they were cropped. The arguments are a bit different, but I did not need xpd=FALSE: emf("TestPlot.emf") barp(t(mydata), col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend.lab=colnames(mydata), legend.pos="topright") dev.off() - David L Carlson Department of Anthropology Texas A University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of EYSSAUTIER Stéphanie Sent: Monday, April 25, 2016 9:53 AM To: r-help@r-project.org Subject: [R] ylim in barplot() Dear useRs, I'm having troubles with using ylim in barplot(): even though I reduce the y-scale using ylim, the bars still extend down to 0into the x-labels. The sample data is below, and here is the code. #This works fine but I would like to plot only from 50 to 70: barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), legend=TRUE, las=2, axis.lty=1) #This is the ylim version with the bar problem: barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend=TRUE, las=2, axis.lty=1) #I have tried using xpd=FALSE and this works fine withinRguior Rstudio but not when I plot within devEMF::emf() barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend=TRUE, las=2, axis.lty=1, xpd=FALSE) I need the emf file to edit the plot. Why isn't it working with ylim alone? And why doesn't xpd work with emf()? Thanks in advance for your help, Stéphanie mydata <- structure(c(68.1799689328282, 68.2164021637813, 68.3243626415103, 61.7899567386469, 59.5182501049449, 63.9916220705152, 64.1442535260522, 64.2585746423512, 62.5653571705887, 61.631969055001, 61.3991475513249, 63.2401411727188, 65.0488808306348, 63.43022364909, 64.8425577471775, 65.4986231824992, 64.7798619682232, 64.4174790601806, 65.5696701695485, 65.0253962620178, 63.2476885701954, 63.2473647791827, 62.5000542212819, 63.1742307643225, 62.1560658393146, 62.5810636272476, 64.0935149828315, 65.5432025084893, 66.7535104579705, 59.6500997601308, 59.4641686257122, 59.8891527196501, 60.0117050975523, 64.3309521324969, 62.0079305659785, 57.0665210362419, 57.5202118193362, 61.3280531011031, 62.6326634763289, 60.2094259175778, 65.5923786551105, 65.6946445059829, 65.2498254841218, 65.3468620859567, 67.024437492438, 65.8533801964148, 65.0047369761726, 65.0310208374089, 64.3121920326177, 64.8038153143374, 63.7306643056964, 64.2579190762784, 67.5745906026732, 67.0351170775703, 66.4053872920113, 59.9302305698358, 60.368722602391, 60.3572311841096, 60.0960412312049, 63.7886894551889, 62.24708719601, 59.3334729073243, 59.9537485303794, 63.1828096654404, 63.5352778562394, 60.621828397375, 65.8889763819732, 66.2059756115814, 66.4567010911873, 65.8796623180062, 67.5552743734229, 66.504738660398, 66.2085036370622, 66.4230781907321, 65.5130180297911, 65.9051623923225, 64.8408013974267, 65.5175045910169, 68.0760225106606, 66.8615536135711, 65.0390748892256, 59.2940092440695, 60.7061368898884, 59.7345965097738, 59.6019925755588, 63.6011933836225, 62.1134684942427, 60.4227073441121, 60.7834352002706, 63.4539745079728, 63.6329498376672, 58.8034486099638, 65.2910772858539, 65.5952764758513, 65.8371262481454, 66.1191053038481, 67.5230043279325, 66.8569714429862, 66.1045642986574, 66.8499631633452,
Re: [R] Linear Regressions with constraint coefficients
This is a quadratic programming problem that you can solve using either a quadratic programming solver with constraints or a general nonlinear solver with constraints. See https://cran.r-project.org/web/views/Optimization.html for more info on what is available. Here is an example using a nonlinear least squares solver and non-negative bound constraints. The constraint that the coefficients sum to 1 is implied by dividing them by their sum and then dividing the coefficients found by their sum at the end: # test data set.seed(123) n <- 1000 X1 <- rnorm(n) X2 <- rnorm(n) X3 <- rnorm(n) Y <- .2 * X1 + .3 * X2 + .5 * X3 + rnorm(n) # fit library(nlmrt) fm <- nlxb(Y ~ (b1 * X1 + b2 * X2 + b3 * X3)/(b1 + b2 + b3), data = list(Y = Y, X1 = X1, X2 = X2, X3 = X3), lower = numeric(3), start = list(b1 = 1, b2 = 2, b3 = 3)) giving the following non-negative coefficients which sum to 1 that are reasonably close to the true values of 0.2, 0.3 and 0.5: > fm$coefficients / sum(fm$coefficients) b1 b2 b3 0.18463 0.27887 0.53650 On Tue, Apr 26, 2016 at 8:39 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, > Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:35 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Subject: Re: Linear Regressions with constraint coefficients > > You need to send it to r-help@r-project.org however. > > Kevin > > On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Ok, will do! Thx a lot! >> >> Please find below my request: >> >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:28 >> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >> Subject: Re: Linear Regressions with constraint coefficients >> >> I believe I approved a message with such a subject. Perhaps there was >> another layer that subsequently rejected it after that. I didn't notice any >> unusual content. Try again, making sure you send the message in plain text >> only. >> >> Kevin >> >> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Do you know where I get help for my issue? >>> >>> Thanks in advance and kind regards, >>> Aljosa >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >>> r-help-ow...@r-project.org >>> Sent: Dienstag, 26. April 2016 14:10 >>> To: Aleksandrovic, Aljosa (Pfaeffikon) >>> Subject: Linear Regressions with constraint coefficients >>> >>> The message's content type was not explicitly allowed >>> > > > -- > Kevin E. Thorpe > Head of Biostatistics, Applied Health Research Centre (AHRC) > Li Ka Shing Knowledge Institute of St. Michael's Hospital > Assistant Professor, Dalla Lana School of Public Health > University of Toronto > email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 > > This email has been sent
Re: [R] Linear Regressions with constraint coefficients
Ok, will try! Thanks a kind regards, Aljosa Aljosa Aleksandrovic, FRM, CAIA Quantitative Analyst - Convertibles aljosa.aleksandro...@man.com Tel +41 55 417 76 03 Man Investments (CH) AG Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland -Original Message- From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Dienstag, 26. April 2016 17:49 To: Aleksandrovic, Aljosa (Pfaeffikon) Cc: r-help@r-project.org Subject: Re: [R] Linear Regressions with constraint coefficients Have you tried web searching on " R constrained linear regression" or similar. There seemed to be resources related to your issues when I looked. You might also search on rseek.org . There are apparently several packages that do regression with constraints, but I don't know if they fit your situation. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 8:29 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Ok, and if I would just like to force my slope coefficients to be inside an > interval, let's say, between 0 and 1? Is there a way in R to formulate such a > constraint regression? > > Thanks in advance and kind regards, > Aljosa > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Bert Gunter [mailto:bgunter.4...@gmail.com] > Sent: Dienstag, 26. April 2016 16:51 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Cc: r-help@r-project.org > Subject: Re: [R] Linear Regressions with constraint coefficients > > If the slope coefficients sum to a constant, the regressors are dependent and > so a unique solution is impossible (an infinity of solutions would result). > So I think you have something going on that you don't understand and should > consult a local statistician to help you formulate your problem appropriately. > > Cheers, > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Tue, Apr 26, 2016 at 5:39 AM, Aleksandrovic, Aljosa (Pfaeffikon) > wrote: >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:35 >> To: Aleksandrovic, Aljosa (Pfaeffikon) >> Subject: Re: Linear Regressions with constraint coefficients >> >> You need to send it to r-help@r-project.org however. >> >> Kevin >> >> On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Ok, will do! Thx a lot! >>> >>> Please find below my request: >>> >>> Hi all, >>> >>> I hope you are doing well? >>> >>> I’m currently using the lm() function from the package stats to fit linear >>> multifactor regressions. >>> >>> Unfortunately, I didn’t yet find a way to fit linear multifactor >>> regressions with constraint coefficients? I would like the slope >>> coefficients to be all inside an interval, let’s say, between 0 and 1. >>> Further, if possible, the slope coefficients should add up to 1. >>> >>> Is there an elegant and not too complicated way to do such a constraint >>> regression estimation in R? >>> >>> I would very much appreciate if you could help me with my issue? >>> >>> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >>> >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> >>> -Original Message- >>> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >>> Sent: Dienstag, 26. April 2016 14:28 >>> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >>> Subject: Re: Linear Regressions
Re: [R] Linear Regressions with constraint coefficients
Have you tried web searching on " R constrained linear regression" or similar. There seemed to be resources related to your issues when I looked. You might also search on rseek.org . There are apparently several packages that do regression with constraints, but I don't know if they fit your situation. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 8:29 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Ok, and if I would just like to force my slope coefficients to be inside an > interval, let's say, between 0 and 1? Is there a way in R to formulate such a > constraint regression? > > Thanks in advance and kind regards, > Aljosa > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Bert Gunter [mailto:bgunter.4...@gmail.com] > Sent: Dienstag, 26. April 2016 16:51 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Cc: r-help@r-project.org > Subject: Re: [R] Linear Regressions with constraint coefficients > > If the slope coefficients sum to a constant, the regressors are dependent and > so a unique solution is impossible (an infinity of solutions would result). > So I think you have something going on that you don't understand and should > consult a local statistician to help you formulate your problem appropriately. > > Cheers, > Bert > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Tue, Apr 26, 2016 at 5:39 AM, Aleksandrovic, Aljosa (Pfaeffikon) > wrote: >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:35 >> To: Aleksandrovic, Aljosa (Pfaeffikon) >> Subject: Re: Linear Regressions with constraint coefficients >> >> You need to send it to r-help@r-project.org however. >> >> Kevin >> >> On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Ok, will do! Thx a lot! >>> >>> Please find below my request: >>> >>> Hi all, >>> >>> I hope you are doing well? >>> >>> I’m currently using the lm() function from the package stats to fit linear >>> multifactor regressions. >>> >>> Unfortunately, I didn’t yet find a way to fit linear multifactor >>> regressions with constraint coefficients? I would like the slope >>> coefficients to be all inside an interval, let’s say, between 0 and 1. >>> Further, if possible, the slope coefficients should add up to 1. >>> >>> Is there an elegant and not too complicated way to do such a constraint >>> regression estimation in R? >>> >>> I would very much appreciate if you could help me with my issue? >>> >>> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >>> >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> >>> -Original Message- >>> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >>> Sent: Dienstag, 26. April 2016 14:28 >>> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >>> Subject: Re: Linear Regressions with constraint coefficients >>> >>> I believe I approved a message with such a subject. Perhaps there was >>> another layer that subsequently rejected it after that. I didn't notice any >>> unusual content. Try again, making sure you send the message in plain text >>> only. >>> >>> Kevin >>> >>> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: Do you know where I get help for my issue? Thanks in advance and kind regards, Aljosa
Re: [R] Linear Regressions with constraint coefficients
Ok, and if I would just like to force my slope coefficients to be inside an interval, let's say, between 0 and 1? Is there a way in R to formulate such a constraint regression? Thanks in advance and kind regards, Aljosa Aljosa Aleksandrovic, FRM, CAIA Quantitative Analyst - Convertibles aljosa.aleksandro...@man.com Tel +41 55 417 7603 Man Investments (CH) AG Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland -Original Message- From: Bert Gunter [mailto:bgunter.4...@gmail.com] Sent: Dienstag, 26. April 2016 16:51 To: Aleksandrovic, Aljosa (Pfaeffikon) Cc: r-help@r-project.org Subject: Re: [R] Linear Regressions with constraint coefficients If the slope coefficients sum to a constant, the regressors are dependent and so a unique solution is impossible (an infinity of solutions would result). So I think you have something going on that you don't understand and should consult a local statistician to help you formulate your problem appropriately. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 5:39 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:35 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Subject: Re: Linear Regressions with constraint coefficients > > You need to send it to r-help@r-project.org however. > > Kevin > > On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Ok, will do! Thx a lot! >> >> Please find below my request: >> >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:28 >> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >> Subject: Re: Linear Regressions with constraint coefficients >> >> I believe I approved a message with such a subject. Perhaps there was >> another layer that subsequently rejected it after that. I didn't notice any >> unusual content. Try again, making sure you send the message in plain text >> only. >> >> Kevin >> >> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Do you know where I get help for my issue? >>> >>> Thanks in advance and kind regards, >>> Aljosa >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >>> r-help-ow...@r-project.org >>> Sent: Dienstag, 26. April 2016 14:10 >>> To: Aleksandrovic, Aljosa (Pfaeffikon) >>> Subject: Linear Regressions with constraint coefficients >>> >>> The message's content type was not explicitly allowed >>> > > > -- > Kevin E. Thorpe > Head of Biostatistics, Applied Health Research Centre (AHRC) > Li Ka Shing Knowledge Institute of St. Michael's Hospital > Assistant Professor, Dalla Lana School of Public Health > University
Re: [R] Linear Regressions with constraint coefficients
If the slope coefficients sum to a constant, the regressors are dependent and so a unique solution is impossible (an infinity of solutions would result). So I think you have something going on that you don't understand and should consult a local statistician to help you formulate your problem appropriately. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Apr 26, 2016 at 5:39 AM, Aleksandrovic, Aljosa (Pfaeffikon)wrote: > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, > Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:35 > To: Aleksandrovic, Aljosa (Pfaeffikon) > Subject: Re: Linear Regressions with constraint coefficients > > You need to send it to r-help@r-project.org however. > > Kevin > > On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Ok, will do! Thx a lot! >> >> Please find below my request: >> >> Hi all, >> >> I hope you are doing well? >> >> I’m currently using the lm() function from the package stats to fit linear >> multifactor regressions. >> >> Unfortunately, I didn’t yet find a way to fit linear multifactor regressions >> with constraint coefficients? I would like the slope coefficients to be all >> inside an interval, let’s say, between 0 and 1. Further, if possible, the >> slope coefficients should add up to 1. >> >> Is there an elegant and not too complicated way to do such a constraint >> regression estimation in R? >> >> I would very much appreciate if you could help me with my issue? >> >> Thanks a lot in advance and kind regards, Aljosa Aleksandrovic >> >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> >> -Original Message- >> From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] >> Sent: Dienstag, 26. April 2016 14:28 >> To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org >> Subject: Re: Linear Regressions with constraint coefficients >> >> I believe I approved a message with such a subject. Perhaps there was >> another layer that subsequently rejected it after that. I didn't notice any >> unusual content. Try again, making sure you send the message in plain text >> only. >> >> Kevin >> >> On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >>> Do you know where I get help for my issue? >>> >>> Thanks in advance and kind regards, >>> Aljosa >>> >>> >>> Aljosa Aleksandrovic, FRM, CAIA >>> Quantitative Analyst - Convertibles >>> aljosa.aleksandro...@man.com >>> Tel +41 55 417 7603 >>> >>> Man Investments (CH) AG >>> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >>> >>> -Original Message- >>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >>> r-help-ow...@r-project.org >>> Sent: Dienstag, 26. April 2016 14:10 >>> To: Aleksandrovic, Aljosa (Pfaeffikon) >>> Subject: Linear Regressions with constraint coefficients >>> >>> The message's content type was not explicitly allowed >>> > > > -- > Kevin E. Thorpe > Head of Biostatistics, Applied Health Research Centre (AHRC) > Li Ka Shing Knowledge Institute of St. Michael's Hospital > Assistant Professor, Dalla Lana School of Public Health > University of Toronto > email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 > > This email has been sent by a member of the Man group (“Man”). Man’s parent > company, Man Group plc, is registered in England and Wales (company number > 08172396) at Riverbank House, 2 Swan Lane, London, EC4R 3AD. > The contents of this email are for the named addressee(s) only. It contains > information which may be confidential and privileged. If you are not the > intended recipient, please notify the sender immediately, destroy this email > and any attachments and do not otherwise disclose or use them. Email > transmission is not a secure method of communication
Re: [R] Linear Regressions with constraint coefficients
Hi all, I hope you are doing well? I’m currently using the lm() function from the package stats to fit linear multifactor regressions. Unfortunately, I didn’t yet find a way to fit linear multifactor regressions with constraint coefficients? I would like the slope coefficients to be all inside an interval, let’s say, between 0 and 1. Further, if possible, the slope coefficients should add up to 1. Is there an elegant and not too complicated way to do such a constraint regression estimation in R? I would very much appreciate if you could help me with my issue? Thanks a lot in advance and kind regards, Aljosa Aleksandrovic Aljosa Aleksandrovic, FRM, CAIA Quantitative Analyst - Convertibles aljosa.aleksandro...@man.com Tel +41 55 417 7603 Man Investments (CH) AG Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland -Original Message- From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] Sent: Dienstag, 26. April 2016 14:35 To: Aleksandrovic, Aljosa (Pfaeffikon) Subject: Re: Linear Regressions with constraint coefficients You need to send it to r-help@r-project.org however. Kevin On 04/26/2016 08:32 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: > Ok, will do! Thx a lot! > > Please find below my request: > > Hi all, > > I hope you are doing well? > > I’m currently using the lm() function from the package stats to fit linear > multifactor regressions. > > Unfortunately, I didn’t yet find a way to fit linear multifactor regressions > with constraint coefficients? I would like the slope coefficients to be all > inside an interval, let’s say, between 0 and 1. Further, if possible, the > slope coefficients should add up to 1. > > Is there an elegant and not too complicated way to do such a constraint > regression estimation in R? > > I would very much appreciate if you could help me with my issue? > > Thanks a lot in advance and kind regards, Aljosa Aleksandrovic > > > > Aljosa Aleksandrovic, FRM, CAIA > Quantitative Analyst - Convertibles > aljosa.aleksandro...@man.com > Tel +41 55 417 7603 > > Man Investments (CH) AG > Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland > > > -Original Message- > From: Kevin E. Thorpe [mailto:kevin.tho...@utoronto.ca] > Sent: Dienstag, 26. April 2016 14:28 > To: Aleksandrovic, Aljosa (Pfaeffikon); r-help-ow...@r-project.org > Subject: Re: Linear Regressions with constraint coefficients > > I believe I approved a message with such a subject. Perhaps there was another > layer that subsequently rejected it after that. I didn't notice any unusual > content. Try again, making sure you send the message in plain text only. > > Kevin > > On 04/26/2016 08:16 AM, Aleksandrovic, Aljosa (Pfaeffikon) wrote: >> Do you know where I get help for my issue? >> >> Thanks in advance and kind regards, >> Aljosa >> >> >> Aljosa Aleksandrovic, FRM, CAIA >> Quantitative Analyst - Convertibles >> aljosa.aleksandro...@man.com >> Tel +41 55 417 7603 >> >> Man Investments (CH) AG >> Huobstrasse 3 | 8808 Pfäffikon SZ | Switzerland >> >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of >> r-help-ow...@r-project.org >> Sent: Dienstag, 26. April 2016 14:10 >> To: Aleksandrovic, Aljosa (Pfaeffikon) >> Subject: Linear Regressions with constraint coefficients >> >> The message's content type was not explicitly allowed >> -- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Hospital Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 This email has been sent by a member of the Man group (“Man”). Man’s parent company, Man Group plc, is registered in England and Wales (company number 08172396) at Riverbank House, 2 Swan Lane, London, EC4R 3AD. The contents of this email are for the named addressee(s) only. It contains information which may be confidential and privileged. If you are not the intended recipient, please notify the sender immediately, destroy this email and any attachments and do not otherwise disclose or use them. Email transmission is not a secure method of communication and Man cannot accept responsibility for the completeness or accuracy of this email or any attachments. Whilst Man makes every effort to keep its network free from viruses, it does not accept responsibility for any computer virus which might be transferred by way of this email or any attachments. This email does not constitute a request, offer, recommendation or solicitation of any kind to buy, subscribe, sell or redeem any investment instruments or to perform other such transactions of any kind. Man reserves the right to monitor, record and retain all electronic and telephone communications through its network in accordance with applicable laws and regulations. --UwQe9f5k7pI3vplngP __ R-help@r-project.org mailing list --
[R] Penalised spline regression
Good Afternoon Everyone, I am looking for advice fitting a linear mixed model where the random components do not seem to fit within the model formulae for lmer. The columns of Z are not stratified and have the notional random formula (z1 | 1) + ... + (zk | 1). Context I am fitting a penalised thin plate spline with knots k1 to kn. The basis functions Zk are |x-ki|^3 and the penalty matrix has elements |ki-kj|^3. Rather than fit basis functions Zk I have transformed the basis to Z = Zk %*% penalty^(-1/2). Full details are in section 2: Bayesian analysis for penalised spline regression using winBUGS. https://www.jstatsoft.org/article/view/v014i14/v14i14.pdf I am specifically looking for an alternative to the function spm() in package semipar. Thank you for any help or advice. Dave. David Mcnulty Medical Statistician Tel: +44 (0) 121 371 2448 Internal: 12448 Email: david.mcnu...@uhb.nhs.uk Web: http://www.uhb.nhs.uk Health Informatics - University Hospitals Birmingham NHS Foundation Trust Yardley Court, 11-13 Frederick Road, Edgbaston Birmingham, B15 1JD The Health Informatics Department is a team of specialist NHS information analysts who work together to provide analysis solutions. The Team filters, analyses and presents comprehensive information that empowers NHS professionals to make informed decisions. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Issue while building xtable on R on Ubuntu 15.04
Please help in the below mentioned issue. Regards Zaid Golwala -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Zaid Golwala Sent: Wednesday, April 06, 2016 1:35 PM To: r-help@R-project.org Subject: [R] Issue while building xtable on R on Ubuntu 15.04 Hi, I am trying to build xtable on R on Ubuntu 15.04 but I get following error : + R CMD check --no-vignettes --timings xtable_1.8-2.tar.gz * using log directory '/home/jenkins/workspace/Rlang_xtable_Ubuntu15.04/xtable.Rcheck' * using R version 3.2.3 (2015-12-10) * using platform: powerpc64le-unknown-linux-gnu (64-bit) * using session charset: UTF-8 * using option '--no-vignettes '* checking for file 'xtable/DESCRIPTION' ... OK * this is package 'xtable' version '1.8-2' * checking package namespace information ... OK * checking package dependencies ...Error in .build_vignette_index(vigns) : In 'inst' vignettes 'xtableGallery.Rnw' and 'xtableGallery.snw' have the same vignette name Can someone please help me regarding the same. Regards Zaid Golwala DISCLAIMER\ ==\ This e-mail ...{{dropped:18}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Haplotype network appearance
Hi, I'm doing haplotype networks with the package pegas and the script from Jimmy O'Donell's blog. The networks which I obtain are a little ugly and I'd like to change some aspects of their appearance, but I'm just starting with R and I don't know how to do it. I have the following problems: -Some nodes overlap. I increase the scale.ratio but then I get a tiny legend. So I need to increase the legend or the links in the graphic. I haven't found any way to increase only the links and, as to the legend, I haven't seen a way to adjust its size without creating it apart from the graphic. Is there another way to solve this problem? -Some nodes are very small and labels hide them. As their size is already small, I'd like to know if there is a way of changing its position and put them outside the nodes. -Finally, I get a lot of gray and discontinous lines which I don't understand and I don't know how to remove them. Thanks in advance, Nuria. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Missing Values in Logical Expressions
Hm Based on Jim's data your construction gives me correct result. > Umsatz_2011<-c(1,2,3,4,5,NA,7,8,NA,10) > Kunde_2011<-rep(0:1,5) > Check_Kunde_2011 <- ifelse(is.na(Umsatz_2011) == TRUE & Kunde_2011 == 1, 1, 0) > Check_Kunde_2011 <- factor(Check_Kunde_2011, levels = c(1,0), labels = > c("Check", "OK")) > table(Check_Kunde_2011) Check_Kunde_2011 CheckOK 1 9 So I presume that the problem lies in your data. You should provide some sample of your data either by posting result of str(yourdata) or dput(head(yourdata)) if you want some advice why with correct code you did not get appropriate result. Instead ifelse you can also use Check_Kunde_2011 <- (is.na(Umsatz_2011)&(Kunde_2011==1))*1 to get desired 0/1 vector. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > g.maub...@weinwolf.de > Sent: Tuesday, April 26, 2016 10:10 AM > To: r-help@r-project.org > Subject: [R] Missing Values in Logical Expressions > > Hi All, > > I need to evaluate missing values in my data. I am able to filter these values > and do simple statistics on it. But I do need new variables based on variables > with missing values in my dataset: > > Check_Kunde_2011 <- ifelse(is.na(Umsatz_2011) == TRUE & Kunde_2011 == > 1, 1, 0) > Check_Kunde_2011 <- factor(Check_Kunde_2011, levels = c(1,0), labels = > c("Check", "OK")) > > The new variable is not correctly created. It contains no values: > > table(Check_Kunde_2011) > < table of extent 0 > > > I searched the web but could not find a solution. > > How can I work with variables and missing values in logical expressions? > > Where could I find something about this? > > Kind regards > > Georg > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
Re: [R] Missing Values in Logical Expressions
Hi Georg, You could just use this: Umsatz_2011<-c(1,2,3,4,5,NA,7,8,NA,10) Kunde_2011<-rep(0:1,5) Check_Kunde_2011<- c("OK","Check")[as.numeric(is.na(Umsatz_2011) & Kunde_2011 == 1)+1] Check_Kunde_2011 will be a vector of strings. Jim On Tue, Apr 26, 2016 at 6:09 PM,wrote: > Hi All, > > I need to evaluate missing values in my data. I am able to filter these > values and do simple statistics on it. But I do need new variables based > on variables with missing values in my dataset: > > Check_Kunde_2011 <- ifelse(is.na(Umsatz_2011) == TRUE & Kunde_2011 == 1, > 1, 0) > Check_Kunde_2011 <- factor(Check_Kunde_2011, levels = c(1,0), labels = > c("Check", "OK")) > > The new variable is not correctly created. It contains no values: > > table(Check_Kunde_2011) > < table of extent 0 > > > I searched the web but could not find a solution. > > How can I work with variables and missing values in logical expressions? > > Where could I find something about this? > > Kind regards > > Georg > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Vegemite Function is Cowardly refusing
Ansley Silva gmail.com> writes: > > R version 3.2.2. > library(vegan) > > I was to look at community tables from my dendrograms and am trying out the > vegemite command. This is the error I get: > > Error in vegemite(apst, apst.clusters) : > Cowardly refusing to use longer than 1 char symbols: > Use scale > > I thought the problem was that I was using the log transformed data, but I > tried it on the raw (which is single digit numbers), and still no luck. > Any suggestions would be appreciated. > I imagined that the error message is clear: vegemite only uses one-character symbols (because the result is so compact). The example data you had with this message had numbers up to 55 -- and that is a two-digit number. The message also suggest that you use 'scale' which is an argument of vegemite() to transform numbers to one-charactar symbols. You can also transform your data to to one-digit width yourself, and vegemite() will be happy. cheers, Jari Oksanen __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Missing Values in Logical Expressions
Hi All, I need to evaluate missing values in my data. I am able to filter these values and do simple statistics on it. But I do need new variables based on variables with missing values in my dataset: Check_Kunde_2011 <- ifelse(is.na(Umsatz_2011) == TRUE & Kunde_2011 == 1, 1, 0) Check_Kunde_2011 <- factor(Check_Kunde_2011, levels = c(1,0), labels = c("Check", "OK")) The new variable is not correctly created. It contains no values: table(Check_Kunde_2011) < table of extent 0 > I searched the web but could not find a solution. How can I work with variables and missing values in logical expressions? Where could I find something about this? Kind regards Georg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Antwort: Fw: Re: Creating variables on the fly (SOLVED)
Hi Don, Hi to all readers, many thanks for all your answers and all your help. I adapted Don's code to my data and Don's code does the trick: str(Kunden01) for (year in 2011:2015) { Reeller_Kunde <- paste0("Reeller_Kunde_", year) Umsatz <- paste0("Umsatz_", year) cat('Creating', Reeller_Kunde,'from', Umsatz,'\n') Kunden01[[ Reeller_Kunde ]] <- ifelse( Kunden01[[ Umsatz ]] >= 0, 1, 2) Kunden01[[ Reeller_Kunde ]] <- factor( Kunden01[[ Reeller_Kunde ]], levels=c(1,2), labels= c("NICHT kaufend", "kaufend") ) } str(Kunden01) This way a new variable is created by building it from a string concatenation. I also like the cat() function to document the process within the loop while running the program. Many thanks for your help. Kind regards Georg Von:g.maub...@gmx.de An: g.maub...@weinwolf.de, Datum: 25.04.2016 21:37 Betreff:Fw: Re: [R] Creating variables on the fly > Gesendet: Montag, 25. April 2016 um 19:35 Uhr > Von: "MacQueen, Don"> An: "g.maub...@gmx.de" , "r-help@r-project.org" > Betreff: Re: [R] Creating variables on the fly > > I'm going to assume that Kunden is a data frame, and it has columns > (variables) with names like > Umstatz_2011 > and that you want to create new columns with names like > Kunde_real_2011 > > If that is so, then try this (not tested): > > for (year in 2011:2015) { > nmK <- paste0("Kunde_real_", year) > nmU <- paste0("Umsatz_", year) > cat('Creating',nmK,'from',nmU,'\n') > Kunden[[ nmK ]] <- ifelse( Kunden[[ nmU ]] <= 0, 1, 2) > Kunden[[ nmK ]] <- factor( Kunden[[ nmK ]], >levels=c(1,2), >labels= c("NICHT kaufend", "kaufend") >) > > } > > This little example should illustrate the method: > > > > foo <- data.frame(a=1:4) > > foo > a > 1 1 > 2 2 > 3 3 > 4 4 > > foo[['b']] <- foo[['a']]*3 > > foo > a b > 1 1 3 > 2 2 6 > 3 3 9 > 4 4 12 > > > > -- > Don MacQueen > > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > > > > > > On 4/22/16, 8:52 AM, "R-help on behalf of g.maub...@gmx.de" > wrote: > > >Hi all, > > > >I would like to use a loop for tasks that occurs repeatedly: > > > ># Groups > ># Umsatz <= 0: 1 (NICHT kaufend) > ># Umsatz > 0: 2 (kaufend) > >for (year in c("2011", "2012", "2013", "2014", "2015")) { > > paste0("Kunden$Kunde_real_", year) <- (paste0("Kunden$Umsatz_", year) > ><= 0) * 1 + > >(paste0("Kunden$Umsatz_", year) > > > 0) * 2 > > paste0("Kunden$Kunde_real_", year) <- factor(paste0("Kunden$Umsatz_", > >year), > > levels = c(1, 2), > > labels = c("NICHT > >kaufend", "kaufend")) > > } > > > >This actually does not work due to the fact that the expression > >"paste0("Kunden$Kunde_real_", year)" ist not interpreted as a variable > >name by the R script language interpreter. > > > >Is there a way to assembly variable names on the fly in R? > > > >Regards > > > >Georg > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >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 -- To UNSUBSCRIBE and more, see 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] ylim in barplot()
Thank you David, That's a nice workaround using plotrix::barp(), but that doesn't explain why ylim doesn't work as intended (or at least, as I expect it to work), or why xpd has no influence when using devEMF::emf()... The problem with saving directly in RStudio is that it requires to manually save the plot, and this becomes troublesome when there are a lot of plot commands in a single script. Bests, Ivan (on behalf of Stéphanie) -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.fr -- https://www.researchgate.net/profile/Ivan_Calandra https://publons.com/author/705639/ Le 25/04/2016 21:16, David L Carlson a écrit : If you are using a Windows system, you can Export the plot from RStudio and save it as a metafile without using package devEMF and it will crop the bars with xpd=FALSE. When I used devEMF on a Windows machine, the bars were not cropped with barplot() as you indicated, but when I switched to plotrix::barp() they were cropped. The arguments are a bit different, but I did not need xpd=FALSE: emf("TestPlot.emf") barp(t(mydata), col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend.lab=colnames(mydata), legend.pos="topright") dev.off() - David L Carlson Department of Anthropology Texas A University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of EYSSAUTIER Stéphanie Sent: Monday, April 25, 2016 9:53 AM To: r-help@r-project.org Subject: [R] ylim in barplot() Dear useRs, I'm having troubles with using ylim in barplot(): even though I reduce the y-scale using ylim, the bars still extend down to 0into the x-labels. The sample data is below, and here is the code. #This works fine but I would like to plot only from 50 to 70: barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), legend=TRUE, las=2, axis.lty=1) #This is the ylim version with the bar problem: barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend=TRUE, las=2, axis.lty=1) #I have tried using xpd=FALSE and this works fine withinRguior Rstudio but not when I plot within devEMF::emf() barplot(t(mydata), beside=TRUE, col=c("orange", "green", "yellow", "purple"), ylim=c(50,70), legend=TRUE, las=2, axis.lty=1, xpd=FALSE) I need the emf file to edit the plot. Why isn't it working with ylim alone? And why doesn't xpd work with emf()? Thanks in advance for your help, Stéphanie mydata <- structure(c(68.1799689328282, 68.2164021637813, 68.3243626415103, 61.7899567386469, 59.5182501049449, 63.9916220705152, 64.1442535260522, 64.2585746423512, 62.5653571705887, 61.631969055001, 61.3991475513249, 63.2401411727188, 65.0488808306348, 63.43022364909, 64.8425577471775, 65.4986231824992, 64.7798619682232, 64.4174790601806, 65.5696701695485, 65.0253962620178, 63.2476885701954, 63.2473647791827, 62.5000542212819, 63.1742307643225, 62.1560658393146, 62.5810636272476, 64.0935149828315, 65.5432025084893, 66.7535104579705, 59.6500997601308, 59.4641686257122, 59.8891527196501, 60.0117050975523, 64.3309521324969, 62.0079305659785, 57.0665210362419, 57.5202118193362, 61.3280531011031, 62.6326634763289, 60.2094259175778, 65.5923786551105, 65.6946445059829, 65.2498254841218, 65.3468620859567, 67.024437492438, 65.8533801964148, 65.0047369761726, 65.0310208374089, 64.3121920326177, 64.8038153143374, 63.7306643056964, 64.2579190762784, 67.5745906026732, 67.0351170775703, 66.4053872920113, 59.9302305698358, 60.368722602391, 60.3572311841096, 60.0960412312049, 63.7886894551889, 62.24708719601, 59.3334729073243, 59.9537485303794, 63.1828096654404, 63.5352778562394, 60.621828397375, 65.8889763819732, 66.2059756115814, 66.4567010911873, 65.8796623180062, 67.5552743734229, 66.504738660398, 66.2085036370622, 66.4230781907321, 65.5130180297911, 65.9051623923225, 64.8408013974267, 65.5175045910169, 68.0760225106606, 66.8615536135711, 65.0390748892256, 59.2940092440695, 60.7061368898884, 59.7345965097738, 59.6019925755588, 63.6011933836225, 62.1134684942427, 60.4227073441121, 60.7834352002706, 63.4539745079728, 63.6329498376672, 58.8034486099638, 65.2910772858539, 65.5952764758513, 65.8371262481454, 66.1191053038481, 67.5230043279325, 66.8569714429862, 66.1045642986574, 66.8499631633452, 66.0121950308609, 66.2593339018511, 65.4397264829666, 65.8389305084859), .Dim = c(26L, 4L), .Dimnames = list(c("T40", "T41", "T42", "306iv01", "306iv02", "306iv19", "306iv13", "306iv04", "306iv05", "402iv01", "402iv02", "402iv03", "306iv16", "306iv10", "TG1", "TG2", "TG3", "TG4", "TG5", "TG6", "TG7", "TG8", "TG9", "TG10", "TG11", "TG12"), c("L.mean", "L.mean_T1", "L.mean_T2", "L.mean_T3"))) __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see