[R] Problem with using flexmix for regression mixtures
Hi there, I would like to conduct a mixture regression analysis with the flexmix Package. Was just playing around with the function stepFlexmix() and did not get a foot into the door. When I run the stepFlexmix-function, I get the following error (actually a list of errors that repeats this sentence: Error in FLXfit(model = model, concomitant = concomitant, control = control, : 26 Log-likelihood: Inf The X-Variable is very skewed (percentages of females in top management teams; many zeros); missing data were omitted. The code was: M1 <- stepFlexmix(rel_perf ~ prozfem, data = cdata2, k = 1:5, nrep = 5) I would appreciate any hint what the problem might be. Thanks in advance, Holger __ 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] Eliminating case numbers in a dendrogram
Hi folks, I conducted a hierarchical cluster analysis. As I wanted to illustrate the result, I created a dendrogram with the code plot(as.dendrogram(fit),sub="",xlab="",ylab="Heterogeneity",nodePar = list(lab.cex=.5,pch=NA,xlab="")) However, the dendrogram contains the case numbers and, as I have N = 300, looks not very nice. Can anybody tell me how to prevent the case numbers? Thanks in advance Holger http://r.789695.n4.nabble.com/file/n2293207/Dendrogram.jpeg -- View this message in context: http://r.789695.n4.nabble.com/Eliminating-case-numbers-in-a-dendrogram-tp2293207p2293207.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hausman test for endogeneity
Dear folks, can anybody point me in the right direction on how to conduct a hausman test for endogeneity in simultanous equation models? Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-test-for-endogeneity-tp2969522p2969522.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hausman test for endogeneity
Dear Liviu, thank you very much. After inspecting the options, I *guess* that systemfit is what I need. However, I absolutely don't understand how it works. I searched long for a detailed documentation (beyond the rather cryptic standard documentation) but found none. Has anybody references/advises how to conduct the test? Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-test-for-endogeneity-tp2969522p2970261.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hausman test for endogeneity
Dear Arne, this looks promising! Thank you very much. Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-test-for-endogeneity-tp2969522p2970564.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hausman Test
Hi, can anybody tell me how the Hausman test for endogenty works? I have a simulated model with three correlated predictors (X1-X3). I also have an instrument W for X1 Now I want to test for endogeneity of X1 (i.e., when I omit X2 and X3 from the equation). My current approach: library(systemfit) fit2sls <- systemfit(Y~X1,data=data,method="2SLS",inst=~W) fitOLS <- systemfit(Y~X1,data=data,method="OLS") print(hausman.systemfit(fitOLS, fit2sls)) This seems to work fine. However, when I include X2 as a furter predictor, the 2sls-estimation doesn't work. Thanks in advance Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-Test-tp3220016p3220016.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hausman Test
Dear Achim, thank you very much. One follow up question. The Hausman-test always gives me a p-value of 1 - no matter how small the statistic is. I now generated orthogonal regressors (X1-X3) and the test gives me Hausman specification test for consistency of the 3SLS estimation data: data Hausman = -0.0138, df = 2, p-value = 1 What is confusing to me is the "3SLS". I am just beginning to learn about instrumental variables (I am a psychologist ;) Perhaps that's a problem? As a background, here's the complete simulation: W = rnorm(1000) X2 = rnorm(1000) X3 = rnorm(1000) X1 = .5*W + rnorm(1000) Y = .4*X1 + .5*X2 + .6*X3 + rnorm(1000) data = as.data.frame(cbind(X1,X2,X3,Y,W)) fit2sls <- systemfit(Y~X1,data=data,method="2SLS",inst=~W) fitOLS <- systemfit(Y~X1,data=data,method="OLS") print(hausman.systemfit(fitOLS, fit2sls)) Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-Test-tp3220016p3220065.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hausman Test
Thank you both very much ! This helped me a lot. Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Hausman-Test-tp3220016p3220123.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simulating correlations with varying sample sizes
Hi there, I would like to draw 10 correlations from a bivariate population - but every draw should be done with a different sample size. I thought I could to this with a loop: r=numeric(10) #Goal vector N = c(1000,100,80,250,125,375,90,211,160,540) #Sample size vector for(i in 1:10) { data <- mvrnorm(n=N,mu=c(0,0),Sigma=matrix(c(1,.3,.3,1),2)) r[i] <- cor(data[,1],data[,2]) } Goal: The 10 correlations shall be contained in the r-vector. However, this does not work. I get an error that "arguments do not match" Has anybody an idea? Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Simulating-correlations-with-varying-sample-sizes-tp3526231p3526231.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulating correlations with varying sample sizes
Wow, this was fast and helpful! Thank you very much. Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Simulating-correlations-with-varying-sample-sizes-tp3526231p3526288.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Metafor: Differences between two categories of a moderator
Hi there, when using the metafor package for testing mixed effects models with categorical moderators, I get a regression table reporting betas. These betas are mean differences between a certain category in the effect size to the reference category (intercept). In addition, the QM-tests allows testing if the differences between all the categories TO the reference are significant or not. The problem is that if there are differences AMONG the categories (but not to the reference), the QM-test will not notice that. Hence, my question is if there is an option to test differences among specific categories (e.g., simple subgroup comparison). Best, Holger -- View this message in context: http://r.789695.n4.nabble.com/Metafor-Differences-between-two-categories-of-a-moderator-tp3562778p3562778.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Metafor: Differences between two categories of a moderator
Hi Wolfgang that's good news. One further small follow-up question: When I conduct multiple comparisons via the relevel-command: should I adjust the p-value? Thanks in advance, Holger -- View this message in context: http://r.789695.n4.nabble.com/Metafor-Differences-between-two-categories-of-a-moderator-tp3562778p3565210.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Box-Cox Transformation: Drastic differences when varying added constants
Dear experts, I tried to learn about Box-Cox-transformation but found the following thing: When I had to add a constant to make all values of the original variable positive, I found that the lambda estimates (box.cox.powers-function) differed dramatically depending on the specific constant chosen. In addition, the correlation between the transformed variable and the original were not 1 (as I think it should be to use the transformed variable meaningfully) but much lower. With higher added values (and a right skewed variable) the lambda estimate was even negative and the correlation between the transformed variable and the original varible was -.91!!? I guess that is something fundmental missing in my current thinking about box-cox... Best, Holger P.S. Here is what i did: # Creating of a skewed variable X (mixture of two normals) x1 = rnorm(120,0,.5) x2 = rnorm(40,2.5,2) X = c(x1,x2) # Adding a small constant Xnew1 = X +abs(min(X))+ .1 box.cox.powers(Xnew1) Xtrans1 = Xnew1^.2682 #(the value of the lambda estimate) # Adding a larger constant Xnew2 = X +abs(min(X)) + 1 box.cox.powers(Xnew2) Xtrans2 = Xnew2^-.2543 #(the value of the lambda estimate) #Plotting it all par(mfrow=c(3,2)) hist(X) qqnorm(X) qqline(X,lty=2) hist(Xtrans1) qqnorm(Xtrans1) qqline(Xtrans1,lty=2) hist(Xtrans2) qqnorm(Xtrans2) qqline(Xtrans2,lty=2) #correlation among original and transformed variables round(cor(cbind(X,Xtrans1,Xtrans2)),2) -- View this message in context: http://r.789695.n4.nabble.com/Box-Cox-Transformation-Drastic-differences-when-varying-added-constants-tp2218490p2218490.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.