Re: [R] glmer.nb: function not in downloaded lme4 package?
Thanks in advance! 2013/5/18 Ben Bolker bbol...@gmail.com Ross Marriott Ross.Marriott at fish.wa.gov.au writes: Dear R Help, I would like to use the glmer.nb function for mixed modelling using negative binomial distribution please. On the CRAN website apparently this function is called from the lme4 package (version 0.9911-1). I have downloaded the latest version of the lme4 package (version 0.99-2) and have recently reinstalled the latest version of 64-bit R (version 3.0.1) but after loading the package and calling: This question would probably be better on the r-sig-mixed-mod...@r-project.org list. glmer.nb() is _only_ in development versions of lme4, not in the stable version on CRAN, and furthermore it is still quite new and poorly tested. If you want to try it out you are probably best of installing from github via install_github in the devtools package. Alternatively you could try the glmmADMB package, on r-forge. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] index of quantile variation (iqv)
Dear all, I would like to compute index of quantile variation (iqv) for each observation in my survey data according to their responses on three categorical variable. Do you know iqv function for this purpose in a package? All the best, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] exporting data into STATA
Dear All, I am not very familiar with ASCII file format, and now I am trying to export R data frame into STATA When I run write.dta command, there is a warning below appear. 5: In abbreviate(ll, 80L) : abbreviate used with non-ASCII chars Do you have any suggestion to fix it? All the bests [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] frequency table-visualization for complex categorical variables
Hi again, Thanks for Anthony about the links on reproducible codes. Thanks for Rui about ordering when rows are intact. One more question Here is your code. x - cbind( sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) ) y - as.matrix( x ) w2 - apply( y , 1 , paste0 , collapse = ) table(w2) Do you know any trick to organize merge certain elements together? For example, if the final table includes BCC, CCB, CBC how should I sum frequency of one element like BCC? I have a very long table it would be indeed very useful! Niklas. 2013/2/25 Rui Barradas ruipbarra...@sapo.pt Hello, I disagree with the way you've sorted the matrix, like this all A's become first, then B's, etc, irrespective of the respondents. Each row is a respondent, and the rows should be kept intact, but with a different ordering. To this effect, use order(): z - y[order(y[,1], y[,2], y[,3]), ] Then use the rest of your code. Or, which would save us the sorting, paste the rows elements together directly from matrix 'y' and use the fact that table() sorts its output. w2 - apply( y , 1 , paste0 , collapse = ) table(w2) Hope this helps, Rui Barradas Em 25-02-2013 18:32, Anthony Damico escreveu: in the future, please provide R code to re-create some example data :) read http://stackoverflow.com/**questions/5963269/how-to-make-** a-great-r-reproducible-**exampleforhttp://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-examplefor more detail.. # create a data table with three unique columns' values.. # treat these values just like letters x - cbind( sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) ) # look at x.. this is good data i hope? x # convert this to a matrix y - as.matrix( x ) # i don't think you care about ordering, so sort left-to-rightwards z - apply( y , 2 , sort ) # look at your results z # paste these results together across the matrix w - apply( z , 1 , paste0 , collapse = ) # count the final distinct results table( w ) On Mon, Feb 25, 2013 at 1:04 PM, Niklas Fischer niklasfischer...@gmail.com**wrote: Dear R users, I have three questions measuring close relationships. The questions are same and the respondents put the answer in order. I'd like to examine the pattern of answers and visualize it. For example q1 (A,B,C,D,E) and q2 and q3 are the same. If the respondents selects A B C (so BCA or BAC or CBA or CAB), I'd like to construct frequency table for ABC and other combinations for example DEF. Unfortunately, there are many answers, and three-way contingency table includes lots of cells which make it diffucult to interpret and requires lots of extra work to organize data. What is the best way to construct fruequency table of these kind of variables and to visulize the results with the most simple form All the bests, Niklas [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] frequency table-visualization for complex categorical variables
Thanks Rui, It is very useful indeed. Bests, Niklas 2013/2/26 Rui Barradas ruipbarra...@sapo.pt Hello, I'm not sure I understand, do you want to treat BCC, CBC and CCB as the same? If so try w2 - apply( y , 1 , function(x) paste0(sort(x) , collapse = )) table(w2) Hope this helps, Rui Barradas Em 26-02-2013 13:58, Niklas Fischer escreveu: Hi again, Thanks for Anthony about the links on reproducible codes. Thanks for Rui about ordering when rows are intact. One more question Here is your code. x - cbind( sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) ) y - as.matrix( x ) w2 - apply( y , 1 , paste0 , collapse = ) table(w2) Do you know any trick to organize merge certain elements together? For example, if the final table includes BCC, CCB, CBC how should I sum frequency of one element like BCC? I have a very long table it would be indeed very useful! Niklas. 2013/2/25 Rui Barradas ruipbarra...@sapo.pt Hello, I disagree with the way you've sorted the matrix, like this all A's become first, then B's, etc, irrespective of the respondents. Each row is a respondent, and the rows should be kept intact, but with a different ordering. To this effect, use order(): z - y[order(y[,1], y[,2], y[,3]), ] Then use the rest of your code. Or, which would save us the sorting, paste the rows elements together directly from matrix 'y' and use the fact that table() sorts its output. w2 - apply( y , 1 , paste0 , collapse = ) table(w2) Hope this helps, Rui Barradas Em 25-02-2013 18:32, Anthony Damico escreveu: in the future, please provide R code to re-create some example data :) read http://stackoverflow.com/questions/5963269/how-to-make-http://stackoverflow.com/**questions/5963269/how-to-make-** a-great-r-reproducible-exampleforhttp://** stackoverflow.com/questions/**5963269/how-to-make-a-great-r-** reproducible-exampleforhttp://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-examplefor more detail.. # create a data table with three unique columns' values.. # treat these values just like letters x - cbind( sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) , sample( LETTERS[1:6] , 100 , replace = TRUE ) ) # look at x.. this is good data i hope? x # convert this to a matrix y - as.matrix( x ) # i don't think you care about ordering, so sort left-to-rightwards z - apply( y , 2 , sort ) # look at your results z # paste these results together across the matrix w - apply( z , 1 , paste0 , collapse = ) # count the final distinct results table( w ) On Mon, Feb 25, 2013 at 1:04 PM, Niklas Fischer niklasfischer...@gmail.comwrote: Dear R users, I have three questions measuring close relationships. The questions are same and the respondents put the answer in order. I'd like to examine the pattern of answers and visualize it. For example q1 (A,B,C,D,E) and q2 and q3 are the same. If the respondents selects A B C (so BCA or BAC or CBA or CAB), I'd like to construct frequency table for ABC and other combinations for example DEF. Unfortunately, there are many answers, and three-way contingency table includes lots of cells which make it diffucult to interpret and requires lots of extra work to organize data. What is the best way to construct fruequency table of these kind of variables and to visulize the results with the most simple form All the bests, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.R-project.org/**posting-guide.html http://www.**R-project.org/posting-guide.**htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted
[R] colineraity among categorical variables (multinom)
Dear all users, Id like to ask you how to make decision about colinearity among categorical independent variables when the model is multinomial logistic regression. Any help is appreciated, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] colineraity among categorical variables (multinom)
Btw, I tried out variance inflation factor(vif) but it works for glm models(lm) but not multinom or nnet class Bests, 2012/11/10 Niklas Fischer niklasfischer...@gmail.com Dear all users, Id like to ask you how to make decision about colinearity among categorical independent variables when the model is multinomial logistic regression. Any help is appreciated, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error about xtable and addmargins
Dear all, Tried to add column margins of a sample data. The data was extracted from xtable library, it gives erroro the below, appreciated if you have any idea. Bests, head(iris) irisk-head(iris) table-xtable(irisk,digits=2) table2 - xtable(addmargins(as.matrix(irisk), 2), digits = 0) Error in FUN(newX[, i], ...) : invalid 'type' (character) of argument [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create new variable with ifelse? (reproducible example)
Thank you very much for very valuable comments. They are very informative. Bests, Niklas 2012/9/16 Ted Harding ted.hard...@wlandres.net [See at end] On 15-Sep-2012 20:36:49 Niklas Fischer wrote: Dear R users, I have a reproducible data and try to create new variable clo is 1 if know variable is equal to very well or fairly well and getalong is 4 or 5 otherwise it is 0. [A] rep_data- read.table(header=TRUE, text= id1id2know getalong 10016_a1 10016_a2 very well4 10035_a1 10035_a2 fairly well NA 10036_a1 10036_a2 very well3 10039_a1 10039_a2 very well5 10067_a1 10067_a2 very well5 10076_a1 10076_a2 fairly well5 ) rep_data$clo- ifelse((rep_data$know==c(fairly well,very well) rep_data$getalong==c(4,5)),1,0) For sure, something must be wrong, I couldn't find it out. rep_data id1id2 know getalong clo 10016_a1 10016_a2 very well4 0 10035_a1 10035_a2 fairly well NA 0 10036_a1 10036_a2 very well3 0 10039_a1 10039_a2 very well5 0 10067_a1 10067_a2 very well5 0 10076_a1 10076_a2 fairly well5 0 Any help is appreciated.. Bests, Niklas There are several things wrong with the way you are trying to do it, and indeed it is a bit complicated! First: if the above table (at [A] above) is the format in which you input the data, then you should either comma-separate your data fields (and use sep=, in read.table(), or else just use read.csv()), or else enclose the two-word fields within ..., i.e. EITHER: [B] id1, id2, know, getalong 10016_a1, 10016_a2, very well,4 10035_a1, 10035_a2, fairly well, NA 10036_a1, 10036_a2, very well,3 10039_a1, 10039_a2, very well,5 10067_a1, 10067_a2, very well,5 10076_a1, 10076_a2, fairly well,5 OR: [C] id1id2know getalong 10016_a1 10016_a2 very well4 10035_a1 10035_a2 fairly well NA 10036_a1 10036_a2 very well3 10039_a1 10039_a2 very well5 10067_a1 10067_a2 very well5 10076_a1 10076_a2 fairly well5 Otherwise, in your original format, read.table() will read in FIVE fields, since it will treat very and well as separate, and will treat fairly and well as separate. Furthermore, it will match the header getalong with the 5th field (4,NA,etc), the header know with the 4th field (well,well,...,well), header id2 with the 3rd field (very,fairly,very,...,fairly), and header id1 with the 2nd field (10016_a2). And even further more, the first field will become the row-names of the dataframe and will no longer be data! Second: Use of == to compare $know with very well and fairly well will not work as you expect. In your comparison rep_data$know==c(fairly well,very well) you will get the result: # [1] FALSE FALSE FALSE TRUE FALSE FALSE rather then your expected # [1] TRUE TRUE TRUE TRUE TRUE TRUE. This is because == will compare $know with ONE ELEMENT of c(fairly well,very well), and will recycle these elements, so it will compare $know successively with fairly well,very well fairly well,very well fairly well,very well and since $know is very well,fairly well,very well,very well,very well,fairly well the only match is in the 4th instance, which is why you get # [1] FALSE FALSE FALSE TRUE FALSE FALSE A better comparison is to use the %in operator, as in: rep_data$know %in% c(fairly well,very well) # [1] TRUE TRUE TRUE TRUE TRUE TRUE so you can in the end do: rep_data$clo- ifelse((rep_data$know %in% c(fairly well,very well)) (rep_data$getalong %in% c(4,5)),1,0) which results in: rep_data #id1 id2know getalong clo # 1 10016_a1 10016_a2 very well4 1 # 2 10035_a1 10035_a2 fairly well NA 0 # 3 10036_a1 10036_a2 very well3 0 # 4 10039_a1 10039_a2 very well5 1 # 5 10067_a1 10067_a2 very well5 1 # 6 10076_a1 10076_a2 fairly well5 1 Finally, I suppose it is a happy coincidence that NA %in% c(4,5) yields FALSE rather than what R might have been written to yield, i.e. NA -- since NA is basically a synonym for something that we do not know the value of, strictly speaking we do not know the value of NA %in% c(4,5). It is possible that the something that we do not know the value of could be either 4 or 5, in which case NA %in% c(4,5) would be TRUE; but it is also possible that the something that we do not know
Re: [R] create new variable with ifelse? (reproducible example)
Thanks Rui and Stephen, They look very interesting. I am glad there are many ways to do so. All the bests, 2012/9/16 Rui Barradas ruipbarra...@sapo.pt Hello, Here's another one. logic.result - with(rep_data, know %in% c(very well, fairly well) getalong %in% c(4,5)) rep_data$clo - 1*logic.result # coerce to numeric Rui Barradas Em 16-09-2012 13:29, Stephen Politzer-Ahles escreveu: Hi Niklas, I like A.K.'s method. Here's another way to do what I think is the same thing you're asking for (this is how I did it before I knew ifelse() existed!) rep_data$clo - 0 rep_data[ rep_data$know %in% c(very well, fairly well) rep_data$getalong %in% c(4,5),]$clo - 1 Best, Steve -- Message: 25 Date: Sat, 15 Sep 2012 23:36:49 +0300 From: Niklas Fischer niklasfischer...@gmail.com To: r-help@r-project.org Subject: [R] create new variable with ifelse? (reproducible example) Message-ID: CADWGO2zANM_UK8qf=**JLZHRSqgtPC=NX+rU2kXx=1etw0uQv** x...@mail.gmail.com 1etw0uqv...@mail.gmail.com Content-Type: text/plain Dear R users, I have a reproducible data and try to create new variable clo is 1 if know variable is equal to very well or fairly well and getalong is 4 or 5 otherwise it is 0. rep_data- read.table(header=TRUE, text= id1id2know getalong 10016_a1 10016_a2 very well4 10035_a1 10035_a2 fairly well NA 10036_a1 10036_a2 very well3 10039_a1 10039_a2 very well5 10067_a1 10067_a2 very well5 10076_a1 10076_a2 fairly well5 ) rep_data$clo- ifelse((rep_data$know==c(**fairly well,very well) rep_data$getalong==c(4,5)),1,**0) For sure, something must be wrong, I couldn't find it out. rep_data id1id2 know getalong clo 10016_a1 10016_a2 very well4 0 10035_a1 10035_a2 fairly well NA 0 10036_a1 10036_a2 very well3 0 10039_a1 10039_a2 very well5 0 10067_a1 10067_a2 very well5 0 10076_a1 10076_a2 fairly well5 0 Any help is appreciated.. Bests, Niklas [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] create new variable with ifelse? (reproducible example)
Dear R users, I have a reproducible data and try to create new variable clo is 1 if know variable is equal to very well or fairly well and getalong is 4 or 5 otherwise it is 0. rep_data- read.table(header=TRUE, text= id1id2know getalong 10016_a1 10016_a2 very well4 10035_a1 10035_a2 fairly well NA 10036_a1 10036_a2 very well3 10039_a1 10039_a2 very well5 10067_a1 10067_a2 very well5 10076_a1 10076_a2 fairly well5 ) rep_data$clo- ifelse((rep_data$know==c(fairly well,very well) rep_data$getalong==c(4,5)),1,0) For sure, something must be wrong, I couldn't find it out. rep_data id1id2 know getalong clo 10016_a1 10016_a2 very well4 0 10035_a1 10035_a2 fairly well NA 0 10036_a1 10036_a2 very well3 0 10039_a1 10039_a2 very well5 0 10067_a1 10067_a2 very well5 0 10076_a1 10076_a2 fairly well5 0 Any help is appreciated.. Bests, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] practical way to change column names?
Dear R helpers, I have a social network data including repated measures of ten alters (whom you contact) and their attributes(gender, age, strength of tie). I wrote variables related with alters just for wrote alter 1 and alter 2. I'd like to change the like below. I'd change each name separetely. Do you know any pratical way to change it? All the bests, Niklas variables for alter 1 g61a (id) g62a (gender) g63a (age) g63aa (tie) g63aan (tie friequency) variables for alter 2 g61b g62b g63b g64b g64bb g64bbn new names alterid_1 alterag_1 alteraa_1 alatert_1 altersf_1 alterid_2 alterag_2 alteraa_2 alatert_2 altersf_2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting and combining statistics like BIC, Rsquare
Dear all, I'd like to ask you if there is a way to combine Rsquare, BIC, AIC values after making imputations in R. There are five data sets I imputed with mice and and than when I create new variable and apply ologit model, I could extract Beta coefficients and its standard errors, but don't know how to extract these statistics above because they cannot with variance or covariance function. Do you know alternative ways? Bests Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] converting list/data.frame to mids/mi object (multiple imputation)
Dear R Users, After imputation, I've created latent variable, but couldn't convert it back to mids object. Do you have any suggestion how to convert data.frame/list to mids(for mice) or mi(for mi pakcage) Any help is appreciated. Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to pool imputed data sets with latent class analysis and binary logistic regression
Dear All, I've used mice package for my latent class analysis and binary logistic regression I've imputed five data sets and with long format I've added new variable that shows latent class membership. And then in addition to other variables, I'll use binary logistic regression and try to pool the estimates. However I couldn't create data.frame to mids objects, and therefore it produced the error below: Error in pool(fit) : The object must have class 'mira' Do you have any suggestions? I'd appreciated if you have time and respond my e-mail. Bests, Niklas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.