regression

Output each factor level as dummy variable in stargazer summary statistics table

假装没事ソ 提交于 2019-12-21 02:58:28
问题 I'm using the R package stargazer to create high-quality regression tables, and I would like to use it to create a summary statistics table. I have a factor variable in my data, and I would like the summary table to show me the percent in each category of the factor -- in effect, separate the factor into a set of mutually exclusive logical (dummy) variables, and then display those in the table. Here's an example: > library(car) > library(stargazer) > data(Blackmoor) > stargazer(Blackmoor[, c(

Clustered Standard Errors with data containing NAs

匆匆过客 提交于 2019-12-20 23:28:26
问题 I'm unable to cluster standard errors using R and guidance based on this post. The cl function returns the error: Error in tapply(x, cluster1, sum) : arguments must have same length After reading up on tapply I'm still not sure why my cluster argument is the wrong length, and what is causing this error. Here is a link to the data set that I'm using. https://www.dropbox.com/s/y2od7um9pp4vn0s/Ec%201820%20-%20DD%20Data%20with%20Controls.csv Here is the R code: # read in data charter<-read.csv

R: Bootstrapped binary mixed-model logistic regression using bootMer() of the new lme4 package

本秂侑毒 提交于 2019-12-20 17:32:08
问题 I want to use the new bootMer() feature of the new lme4 package (the developer version currently). I am new to R and don't know which function should I write for its FUN argument. It says it needs a numerical vector, but I have no idea what that function will perform. So I have a mixed-model formula which is cast to the bootMer(), and have a number of replicates. So I don't know what that external function does? Is it supposed to be a template for bootstrapping methods? Aren't bootstrapping

Two stage least square in R

家住魔仙堡 提交于 2019-12-20 14:19:14
问题 I want to run a two stage probit least square regression in R. Does anyone know how to do this? Is there any package out there? I know it's possible to do it using Stata, so I imagine it's possible to do it with R. 回答1: You might want to be more specific when you say 'two-stage-probit-least-squares'. Since you refer to a Stata program that implements this I am guessing you are talking about the CDSIMEQ package, which implements the Amemiya (1978) procedure for the Heckit model (a.k.a

Time series prediction using R

不羁岁月 提交于 2019-12-20 14:12:28
问题 I have the following R code library(forecast) value <- c(1.2, 1.7, 1.6, 1.2, 1.6, 1.3, 1.5, 1.9, 5.4, 4.2, 5.5, 6, 5.6, 6.2, 6.8, 7.1, 7.1, 5.8, 0, 5.2, 4.6, 3.6, 3, 3.8, 3.1, 3.4, 2, 3.1, 3.2, 1.6, 0.6, 3.3, 4.9, 6.5, 5.3, 3.5, 5.3, 7.2, 7.4, 7.3, 7.2, 4, 6.1, 4.3, 4, 2.4, 0.4, 2.4) sensor<-ts(value,frequency=24) fit <- auto.arima(sensor) LH.pred<-predict(fit,n.ahead=24) plot(sensor,ylim=c(0,10),xlim=c(0,5),type="o", lwd="1") lines(LH.pred$pred,col="red",type="o",lwd="1") grid() The

How to implement the Softmax derivative independently from any loss function?

最后都变了- 提交于 2019-12-20 12:19:14
问题 For a neural networks library I implemented some activation functions and loss functions and their derivatives. They can be combined arbitrarily and the derivative at the output layers just becomes the product of the loss derivative and the activation derivative. However, I failed to implement the derivative of the Softmax activation function independently from any loss function. Due to the normalization i.e. the denominator in the equation, changing a single input activation changes all

forward stepwise regression

喜夏-厌秋 提交于 2019-12-20 12:11:08
问题 In R stepwise forward regression, I specify a minimal model and a set of variables to add (or not to add): min.model = lm(y ~ 1) fwd.model = step(min.model, direction='forward', scope=(~ x1 + x2 + x3 + ...)) Is there any way to specify using all variables in a matrix/data.frame, so I don't have to enumerate them? Examples to illustrate what I'd like to do, but they don't work: # 1 fwd.model = step(min.model, direction='forward', scope=(~ ., data=my.data.frame)) # 2 min.model = lm(y ~ 1, data

Using the glmulti package in R for exhaustive search multiple regression for akaike weights

余生长醉 提交于 2019-12-20 10:53:08
问题 I was wondering if someone could help me understand why I am getting an error message when I enter a script into R. For abit of background information I am looking into the effect 6 different variables (which I think is 63 combinations or models) (X) have on gross primary and net ecosystem production (Y) seperatly at different spatial scales for my environmental science honours project. I have decided to use exhaustive search multiple regression analysis with akaikes information criterion

How to correctly use scikit-learn's Gaussian Process for a 2D-inputs, 1D-output regression?

橙三吉。 提交于 2019-12-20 10:25:12
问题 Prior to posting I did a lot of searches and found this question which might be exactly my problem. However, I tried what is proposed in the answer but unfortunately this did not fix it, and I couldn't add a comment to request further explanation, as I am a new member here. Anyway, I want to use the Gaussian Processes with scikit-learn in Python on a simple but real case to start (using the examples provided in scikit-learn's documentation). I have a 2D input set (8 couples of 2 parameters)

Linear regression with pandas dataframe

十年热恋 提交于 2019-12-20 10:01:17
问题 I have a dataframe in pandas that I'm using to produce a scatterplot, and want to include a regression line for the plot. Right now I'm trying to do this with polyfit. Here's my code: import pandas as pd import matplotlib import matplotlib.pyplot as plt from numpy import * table1 = pd.DataFrame.from_csv('upregulated_genes.txt', sep='\t', header=0, index_col=0) table2 = pd.DataFrame.from_csv('misson_genes.txt', sep='\t', header=0, index_col=0) table1 = table1.join(table2, how='outer') table1 =