standard-error

Add shaded standard error curves to geom_density in ggplot2

天涯浪子 提交于 2019-12-13 12:35:28
问题 I would like to add shaded standard error curves to geom_density using ggplot2 . My code looks like this: data.plot <- data.frame(x = c(rnorm(100, mean = 0, sd = 5), rnorm(100, mean = 1, sd =2 )), g = factor(c(rep(1, 100), rep(2,100)))) ggplot(data.plot, aes(x, linetype = g)) + geom_density() I couldn't find a tutorial or examples to do so. Thank you. 回答1: The best solution is with bootstrapping, as mentioned in the comments. I'll use the classic iris data, focusing on the density of Sepal

geom_errorbar behaving strangely, ggplot2

女生的网名这么多〃 提交于 2019-12-13 07:44:49
问题 I have an usual problem when using geom_errorbar in ggplot2. The error bars are not within range but that is of no concern here. My problem is that geom_errorbar is plotting the confidence intervals for the same data differently depending on what other data is plotted with it. The code below filters the data only passing data where Audio1 is equal to "300SW" OR "3500MFL" in the uncommented SE and AggBar. SE<-c(0.0861829641865964, 0.0296894376485468, 0.0323219002250762, 0.0937013798013447)

R's sandwich package producing strange results for robust standard errors in linear model

只谈情不闲聊 提交于 2019-12-12 03:08:14
问题 I am trying to find heteroskedasticity-robust standard errors in R, and most solutions I find are to use the coeftest and sandwich packages. However, when I use those packages, they seem to produce queer results (they're way too significant). Both my professor and I agree that the results don't look right. Could someone please tell me where my mistake is? Am I using the right package? Does the package have a bug in it? What should I use instead? Or can you reproduce the same results in STATA?

Calculating standard error of estimate, Wald-Chi Square statistic, p-value with logistic regression in Spark

懵懂的女人 提交于 2019-12-10 13:07:59
问题 I was trying to build Logistic regression model on a sample data. The output from the model we can get are the weights of features used to build the model. I could not find Spark API for standard error of estimate, Wald-Chi Square statistic, p-value etc. I am pasting my codes below as an example import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS import org.apache.spark.mllib.evaluation.{BinaryClassificationMetrics, MulticlassMetrics} import org.apache.spark.mllib.linalg

individual random effects model with standard errors clustered on a different variable in R (R-project)

大兔子大兔子 提交于 2019-12-09 19:06:26
问题 I'm currently working on some data from an experiment. Thus, I have data about some individuals who are randomly assigned to 2 different treatments. For each treatment, we ran three sessions. In each session, participants were asked to make a sequence of decisions. What I would like to do is to: (1) estimate the effect of the treatment with a model that includes random effects on individuals and afterwards, (2) clustering the standard errors by session. In R, I can easily estimate the random

first-difference linear panel model variance in R and Stata

雨燕双飞 提交于 2019-12-09 05:47:49
问题 I would like for a colleague to replicate a first-difference linear panel data model that I am estimating with Stata with the plm package in R (or some other package). In Stata, xtreg does not have a first difference option, so instead I run: reg D.(y x), nocons cluster(ID) In R, I am doing: plm(formula = y ~ -1 + x, data = data, model = "fd", index = c("ID","Period")) The coefficients match, but the standard errors in R are larger than in Stata. I looked in the plm help and pdf documentation

Cluster-Robust Standard Errors in Stargazer

孤街浪徒 提交于 2019-12-06 02:55:40
问题 Does anyone know how to get stargazer to display clustered SEs for lm models? (And the corresponding F-test?) If possible, I'd like to follow an approach similar to computing heteroskedasticity-robust SEs with sandwich and popping them into stargazer as in http://jakeruss.com/cheatsheets/stargazer.html#robust-standard-errors-replicating-statas-robust-option. I'm using lm to get my regression models, and I'm clustering by firm (a factor variable that I'm not including in the regression models)

Error computing Robust Standard errors in Panel regression model (plm,R)

和自甴很熟 提交于 2019-12-05 06:14:43
问题 I am using the plm library to run fixed effect regressions and the sandwich,lmtest libraries to compute robust standard errors. I have no problem running the regressions, but in some instances when I go to compute the standard errors I get the following error: library(plm) library(sandwich) library(lmtest) fe_reg <- plm(y ~ x + I(x^2)+factor(date), data=reg_data, index=c("id","date"), model="within") coeftest(fe_reg, vcov.=vcovHC(fe_reg, type="HC1")) RRuntimeError: Error in solve.default

Problem placing error bars at the center of the columns in ggplot()

若如初见. 提交于 2019-12-04 09:42:57
This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 3 years ago . Learn more . I am having a problem with my bar chart- the error bars just appear on the corner of the columns of the grouping variable rather than on them in a centralised way. The code I am using is this: a <- data.frame (Cond = c("In", "In", "Out", "Out"), Temp = c("Hot", "Cool", "Hot", "Cool"), Score = c(.03, -.15, 0.84, 0.25), SE = c(.02, .08, .14, .12)) a.bar <- ggplot (data = a, aes(x = Cond, y = Score, fill = Temp)) + theme_bw() + theme(panel.grid = element_blank ()) +

Cluster-Robust Standard Errors in Stargazer

北城以北 提交于 2019-12-04 07:29:21
Does anyone know how to get stargazer to display clustered SEs for lm models? (And the corresponding F-test?) If possible, I'd like to follow an approach similar to computing heteroskedasticity-robust SEs with sandwich and popping them into stargazer as in http://jakeruss.com/cheatsheets/stargazer.html#robust-standard-errors-replicating-statas-robust-option . I'm using lm to get my regression models, and I'm clustering by firm (a factor variable that I'm not including in the regression models). I also have a bunch of NA values, which makes me think multiwayvcov is going to be the best package