Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer (b) is not *just* about how to use `R`.

learn more… | top users | synonyms

1
vote
0answers
11 views

Modelling a binary outcome when census interval varies

For a current piece of work I’m trying to model the probability of tree death for beech trees in a woodland in the UK. I have records of whether trees were alive or dead for 3 different census periods ...
0
votes
0answers
30 views

Monte Carlo R help needed

I am concerned with the following question. Given a distribution of active days of a developer per period p (let's assume quarters), I want to simulate the threshold of the days required to be ...
0
votes
0answers
9 views

Testing accuracy keeps on increasing. No signs of overfitting

I am trying to do some cross-validating in R. As I am increasing the cost parameter in LiblineaR, the testing accuracy should increase initially, but start to decrease. However, as my cost parameter ...
2
votes
0answers
16 views

Stratum on subset of data: drop if too small?

We have genotype data for ~20000 samples with 4 principal components and 10 strata - study centres. Formula for an example analysis would be: ...
0
votes
0answers
13 views

Raising vector with negative numbers to a fractional exponent in R [migrated]

I have a vector of numbers that contains negative numbers and I would like to raise it to a fractional exponent, but can't quite figure out how to do it. Here is some example code. ...
0
votes
0answers
18 views

Split Plot Design? lmer analysis

I need advice regarding the analysis of a project that I am working at the moment. Here the picture of the experiment: We have an RCBD with four blocks. Within each block there are 5 plots. Each plot ...
1
vote
0answers
7 views

Compare official population distribution with sample?

I have official numbers regarding the population of specific ZIP codes that belong to a certain region, e.g. 90210 has population of 20.000 (just an example). (The set of ZIPs comprises a city and its ...
0
votes
1answer
30 views

What goodness of fit tests, for logistic regression models, are available in R?

I'm planning to work on some credit risk models using logistic regresson in R. Binary response. What all goodness of fit tests are to be known and WHAT PACKAGES are required for the same? Thank you. I ...
-1
votes
1answer
22 views

Split groups in R [on hold]

I am about to do an ANOVA. I have a data set and want to split it in four evenly sized groups ordered by one of the columns. How can I obtain this in R?
1
vote
0answers
22 views

Is there some R package which is able to convert sequences of 0,1 into timeseries visualizing hidden level of phenomena? [on hold]

I found this Figure in book: Zucchini, Walter, and Iain L. MacDonald. Hidden Markov models for time series: an introduction using R. CRC Press, 2009. It perfectly fits to my research. Does ...
1
vote
1answer
13 views

Running Ridge/Lasso regression with glmnet - Intercept shows up twice in the output. Have I done anything wrong?

I'm working my way through the ISLR book and I just finished exercise 9c/d in Chapter 6. For some reason the output I end up getting is showing the intercept twice, with no coefficient for one of the ...
0
votes
0answers
8 views

Intepreting p values from R mediate() output

In the output below, the ACME p value shows that it is significant. But the p-value for Prop. Mediated Average is >10%. I thought Prop. Mediate is the proportion of the total effect mediated by the ...
-1
votes
1answer
18 views

Interpreting kmeans output

I am working on a clustering model with the kmeans() function in the package stats and I have a question about the output. My data is a sample from several tech companies and AAPL._UP is a variable ...
0
votes
0answers
19 views

Please help me to do regression with stable distribution with R [on hold]

I am literally new to R. Is there anyone to make a code to carry out simple AR(1) regression with error terms according on stable distribution? Say $$y(t) = c + by(t-1) + e$$ where $e$ ~ stable ...
1
vote
1answer
21 views

The results and specifics from the 'qs' function in R

I'm not entirely familiar with the results of the qs() function in R's package seasonal. But, by what I understand roughly, the ...
0
votes
0answers
10 views

NAs returned when applying r.squaredGLMM [on hold]

I wish to calculate conditional and marginal R2 values for a linear mixed model. However, R keeps returning 'NAs' for each (no warning message). I have tried a number of model variations and the same ...
1
vote
1answer
27 views

How can I avoid misidentification of a exponential distribution as Gamma or Weibull?

I'm trying to write a piece of code in R that identifies a set of sample data as belonging to a specific distribution and pull the specific distribution parameters, by performing the K-S test and ...
6
votes
4answers
134 views

How can you visualize the relationship between 3 categorical variables?

I have a dataset with three categorical variables and I want to visualize the relationship between all three in one graph. Any ideas? Currently I am using the following three graphs: Each graph is ...
0
votes
0answers
8 views

Bootstrap Step-Wise Selection For GLM in R [migrated]

What I'm trying to do is the following: Resample (bootstrap) the dataset containing my predictors and outcomes, say 1000 times For each bootstrap sample fit a glm using stepwise selection and then ...
0
votes
0answers
4 views

Calculating leverage/cook's distance for a Weighted Spatial Simultaneous Autoregression Model

I am estimating a Weighted Spatial Simultaneous Autoregression Model (spdep::spautolm --> Link) in R and I would like to do some residual analysis. Unfortunately ...
0
votes
0answers
26 views

Repeated measurments with R [on hold]

I read quite a bit of answers on similar questions, but some of them are contradictory. We have several treatments with number of subjects for each one. For each subject we have measurments for ...
0
votes
0answers
9 views

How to do forward stepwise regression using adjusted R^2 in R [on hold]

As I understand, stepwise regression in R uses AIC by default. How can I do forward stepwise regression in R, using "significant improvement in adjusted R squared" as my criterion for adding ...
0
votes
0answers
8 views

XERGM R-package: GOF error with bipartite, temporal ERGM

I was able to estimate the following temporal, bipartite ERGM using the xergm package in R: ...
0
votes
0answers
22 views

correlations between factors in r- scores or loadings?

I've conducted a factor analysis in r with three factors (function=fa {psych};rotation=promax ; method=GLS). ...
7
votes
0answers
65 views

How to test if “previous state” has influence on “subsequent state” in R

Imagine a situation: We have historical records (20 years) of three mines. Does the presence of silver increases the probability of finding gold in next year? How to test such question? Here is ...
0
votes
0answers
15 views

log-likelihood of multivariate regression

I am struggling with R to calculate log-likelihood of multivariate regression (i.e. more than one response, one or more predictors). I would like to have a function taking object of class "mlm" as an ...
3
votes
0answers
52 views

How are outliers dealt with in R after detected? [on hold]

Once outliers in time series are detected in R how exactly are they dealt with before forecasting? I dont want commands to use i would like the method. Please do not give any answers to do with ...
0
votes
0answers
29 views

How to demonstrate biased estimates of linear regression vs cox proportional hazard survival analysis in R?

I want to perform a really simple simulation of right censored data. Then I want to draw a kaplan meir survival curve and do a cox proportional hazards test. Then I also want to perform a simple ...
1
vote
1answer
38 views

How do you get the principal components of one matrix along the principal directions of another matrix?

I have a data matrix, A, on which I have performed principal component analysis (PCA) using the prcomp function in R. This gives me the ...
3
votes
1answer
22 views

How to simulate noisy respondent entry of short textual responses? [on hold]

I have a list of company name as following: ...
0
votes
1answer
22 views

Computing Issues with Kriging

I am having some issues with Kriging in R, and I was looking for some idea where I am going wrong. From what I can tell, I done a decent job removing the trend, and I believe my transformed data is ...
0
votes
0answers
9 views

R: how does caret choose default tuning range? [migrated]

When using R caret to compare multiple models on the same data set, caret is smart enough to ...
0
votes
0answers
15 views

Plotting List of Words with R [on hold]

I am an R beginner in way over his head. I am starting with a list of character vectors. It starts with 25 words. Each year some of these words are pruned from the vectors. I want to plot the list of ...
0
votes
1answer
41 views

k means with binary variables

Is it OK to use kmeans with binary variables? I mean Euclidean distance? I guess the binary variables will be the ones that get the most power to determine the ...
0
votes
0answers
26 views
0
votes
1answer
16 views

assigning column name to a data frame by reading a different file [on hold]

I have created a data frame from a pre given data set which does not have column name.so by default the col names are V1, V2.......V42. Now I have one more file (.txt) which has one column with 41 ...
0
votes
0answers
6 views

adding two transition columns to a dataframe [on hold]

Hello I have a dataframe with 1/0 variable, call it remission I also have another column of patient id's i also have another column of recorded times(not time to achieve remission) just time i want ...
0
votes
0answers
16 views

Interpretation of linear and quadratic interactions

I'm working on building and interpreting multilevel models. In one, I'm predicting binge episodes over time and using a linear time by baseline characteristic interaction as well as a quadratic time ...
2
votes
1answer
52 views

How can a univariate seasonal time series be made normally distrubuted by Box-Cox transformation?

I'm trying to fit a sarima model on the univariate data with 180 points (periodicity=12). I use the auto.arima function in R. After fitting a model to the data, the only problem is the violation of ...
0
votes
0answers
9 views

Error in predict function when training set and test set have different columns [on hold]

I have a dataset which I split into a Test and a Train . On the Train dataset I have done a few preprocessing steps such as Imputing missing values, dummyfying variables, and also added a few extra ...
1
vote
0answers
10 views

Monte-Carlo: R script not returning anything [migrated]

My R script is mcnorm.R <- function(M,N) { library("mvtnorm", lib.loc="~/R/win-library/3.2") R <- as.matrix(read.csv("Data.csv", header=FALSE)) mu <- colMeans(R) ...
1
vote
0answers
15 views

F-Test for Equality of Variances with Weighted Survey Data

I would like to use an F-Test for Equality of Variances on a variable to compare two groups. Normally, this would be done with an sdtest command in Stata or a ...
0
votes
1answer
37 views

Best ways to model 'big data' given limited computing resources

Suppose I have a large data set(10 GB), with a response variable and multiple independent variables. What is the best way to utilize the data to build a model on? If the full data set includes 10 ...
0
votes
0answers
24 views

Standard deviation error bars and kruskal.test in R

I need to test if there is a significant difference between two groups of data, each with three replicates. (Multiple groups) I used the following approach: ...
0
votes
1answer
27 views

Histogram in R from two vectors [on hold]

how can I create a histogram in R from known values and counts? Thing is, I need to change manually h\$counts in my data set, so I have no data for that new histogram with changed values in h\$counts. ...
0
votes
0answers
13 views

Variable selection via mutual information

I am building a SVM model and was wondering whether filtering variables based on mutual information between response variable(binary 0/1 variable)is a good approach? Also, would the condinformation ...
0
votes
1answer
15 views

How to return all a particular column in a data frame

Suppose I have a data frame mysample. When I try to access only the second column using mysample[,2] I get a single element. How do I return the second column of the data frame?