Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

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`.

0
votes
0answers
2 views

Is it appropriate to use estimated marginal means when model estimates are not significant but data is unbalanced?

Is it appropriate to use estimated marginal means when estimates (either interaction or main effects) are not significant but the data is unbalanced? I've come across variations of this question on ...
1
vote
0answers
4 views

parallel mediation with more than 2 mediators

i am an absolute noob when it comes to R programming but, alas, I have a college course I have to attend (and pass) and i am really, coming from social sciences, struggling. we're doing this ...
1
vote
0answers
20 views

Error while fitting data in auto.arima - R

I am running auto.arima for forecasting time series data and getting the following error: ...
0
votes
0answers
7 views

Probit with Selection Bias (using sampleSelection library)

I'm trying to find a library in R that performs Probit with Selection Bias. I found the library sampleSelection, but I am not getting the expected results. Here's my code: ...
3
votes
2answers
143 views

Why is arima in R one time step off?

I've recently noticed an odd behavior in a few timeseries methods. Let's fit an arima model (ar1) to the annual subspots data ...
0
votes
0answers
12 views

optimization of the index of a vector in R [on hold]

dear members, I am stock trader based in INDIA, at Bangalore. During the course of my research, I stumbled upon a very novel type of optimization. I have worked around for a while, but ...
0
votes
0answers
9 views

Understanding the Cullen and Frey plot

I would like to figure out which distribution fits my data best. Here is the histogram of my data : I used the fitdistrplus package in R to try to find the best ...
0
votes
0answers
6 views

Which statistical analysis should I use (on R) on a multivariate GAMM accounting for spatial autocorrelation?

Part 1 : Including categorical variable in my formula I have 3 dependent variables (DVs ; Y1, Y2, Y3) which are continuous and 2 independent variables (IVs) with one which is continuous (X1) and the ...
0
votes
0answers
6 views

R-Optimization of multiple parameters: the optimized parameters are the same as the initials

I am optimizing 54 parameters and the code is shown below. I tried several packages such as optimx and Rcgmin, and the results are pretty much the same as the initial values I set, which I knew was ...
0
votes
0answers
14 views

Why does the inverse gamma distribution look essentially the same when increasing the variance?

I have a function in R which for a given mean $\mu$ and variance $\sigma^2$, spits out the parameters for the shape, $\alpha$, and rate, $\beta$ of the inverse gamma distribution with that mean and ...
0
votes
0answers
8 views

Multiple Lags with Dplyr [migrated]

I refer to the excellent post at https://purrple.cat/blog/2018/03/02/multiple-lags-with-tidy-evaluation/ What I want to do is to create a function capable, à la dplyr, to generate new columns which ...
0
votes
0answers
23 views

Regression analysis Interpretation [duplicate]

How do I interpret these results? Specifically, what does this regression analysis show us? How do we determine which values are statistically significant? I don't have problem with the coding. I just ...
3
votes
1answer
292 views

Calculating the expected value of truncated normal

Using the mills ratio result, let $X \sim N(\mu, \sigma^2)$, then $E(X| X<\alpha) = \mu - \frac{\phi(\frac{a- \mu}{\sigma})}{\Phi(\frac{a-\mu}{\sigma})}$ However, when calculating it in R. I don'...
0
votes
0answers
20 views

how to provide the lambda values to Glmnet in r?

here I want to perform Lasso-cross-validation on some data to find the optimal value of lambda. I chose the R platform and hence come across the Glmnet package in R. https://web.stanford.edu/~hastie/...
1
vote
1answer
34 views

What stats tests can be used to find whether the increase/decrease in counts yearly are difference statistically?

I have read posts about the similar problems in the forum and they are suggesting using regression to see if there is any significant increases/decrease. I have data for 3 years and their counts i.e. ...
1
vote
0answers
18 views

Equating two different sample sizes [on hold]

I have two scores, Score 1 and score 2. Score 1 has 150 samples and Score 2 has 85 samples. Is it possible to equate scores, especially using R packages?
0
votes
1answer
21 views

INAR(1) simulation in R [on hold]

How do we simulate values of $Y_t$ for a maximum value of $t=60$ when we have an INAR(1) process as follows: $Y_t=ρ^*Y_{(t-1)}+R_t$ where $t$ takes values from 1 to 60, $ρ=0.3,0.8$, $ρ^*$ is ...
0
votes
1answer
25 views

Linear Forecasting with a small dataset

I am trying to get some forecast (5 years more) from a small dataset that is as follows: ...
0
votes
0answers
6 views

Repeated Measures with Nested Random Effects [on hold]

I'm working on a study involving cookie recipes. There are 3 levels of sugar: half, normal, and double. Within each level of sugar, there are 3 random batches, labeled 1 to 9. On 3 consecutive days, 5 ...
0
votes
0answers
7 views
0
votes
0answers
13 views

Is my data inappropriate for a zero-inflated regression model?

I am working with count data where I have an abundance of zeros for one of my categorical factors (Day). I have generated two models, p1 and m1, with zeroinfl() and ...
0
votes
0answers
16 views

How to transform my data appropriately? [on hold]

When I did time series analysis and plot the time series plot, the plot shows non-constant variance. How can I process it if the plot like this.
0
votes
1answer
19 views

How to interpret glm output for quasi-binomial model

I am having difficulty interpreting the output for a quasibinomial model. My first issue is that I have used the function 'autoplot' to test assumptions, and the normal Q-Q plot is skewed: I am ...
0
votes
0answers
15 views

Is my objective function to optimize svm parameters right? [migrated]

I have this objective function to optimize SVM parameters using PSO. ...
-1
votes
0answers
15 views

ggsave gives blank jpeg image [migrated]

I am trying to save my plots in my R script. I used the following context: ...
1
vote
0answers
11 views

Randomized Block Design Models

I have been asked to fit the following models in R: The models are based on this data: I know the mediums are the blocks and the units of the active ingredient are the treatments. I understand how ...
1
vote
0answers
13 views

How to fix this error p<0! while optimizing SVM using PSO? [on hold]

I am trying to optimize SVM paramters for a regression problem using PSO in R. I am getting this weird error. Any suggestion on how to fix this error would be greatly appreciated. Error in svm....
0
votes
1answer
14 views

What is the corresponding model when I include drift in an SARIMA model with seasonal differences?

I fitted the following model, but I am not sure if the drift term is an intercept term or the mean of $y_t-y_{t-4}$ (as it seems in a blog post by Rob Hyndman). ...
0
votes
1answer
23 views

Dealing with missing month values in dataset and plotting a time series

So i currently have a dataset in R: ...
0
votes
0answers
6 views

MDS for word vectors: Weighting and distance measures

I calculated a Latent Dirichlet Allocation (LDA) based customer reviews for three different smartphone brands. The topics represent the attributes of the brands. I want to map the single topics on an ...
1
vote
1answer
22 views

linear mixed model: visualising fixed effect and interaction with continuous variable (with confidence interval)

My aim is to analyse the blood concentration of a biomarker and its annual increase in four different subject groups using longitudinal measurements, i.e. biomarker concentrations of each subject were ...
0
votes
0answers
15 views

Variable importance Plot for a categorical variable in R [on hold]

The input variables for training random forest algorithm are given in the table. From the research article Random forest based hourly building energy prediction In that day type, workday type and time ...
0
votes
0answers
7 views

R package topicmodels, how are probabilities calculated in case of trained model with new text [on hold]

When scoring new text documents with a trained topic model (LDA() function in r package topic model) the posterior() function ...
1
vote
1answer
29 views

How can I make a Kolmogorov-Smirnov test to check if my data distribution is exponential?

I made a histogram of my data, and the fitting line, but from some reason the fitting line doesn't fit to my graph. How can I make it fit to it? How can I check if my data distribution is exponential?...
0
votes
0answers
29 views

scale with z-transform with the outliers in the data

I have 2 different columns X1, and X2. As you can see scale of X1 is larger than X2. These 2 columns represent the predicted value of performance of my two products. However the range or scale of X1 ...
-2
votes
0answers
14 views

colMenas() function! [on hold]

I have to use colMeans() in order to get a column mean of the data here, the data set is like ...
0
votes
0answers
14 views

Nested sampling with dplyr in R [migrated]

trying to sample "all in one shot" through dplyr pipes. Check this example below: ...
0
votes
1answer
24 views

How to interpret if a COX hazard ratio is dependent on 2 variables

Hi so I'm interested in calculating HR for the following variables. age, state and sex. Univariate calculation using R survival package for example looks something like this. ...
0
votes
1answer
12 views

What if the dispersion parameter of a glmm model is not around 1?

I am using the glmer function in package "lme4". The results shows that: AIC BIC logLik deviance df.resid 96.7 105.5 -44.4 88.7 62 So the dispersion parameter is ...
1
vote
1answer
62 views

Mixed Effect Models - choice of the random intercept

I'm using the glmer function from lme4 package to model a binomial phenomena in a human DNA dataset. An allele can be missing (1) or not (0). The dataset is created with 10 different samples. Each ...
3
votes
1answer
31 views

Zero-inflated model predicting only a small range of values. I need help

I built a ZI model and it is producing predicted values that are from a very small range when compared to the observed values. Plus it does not produce any zeros. See the fitted vs. observed graph ...
2
votes
1answer
333 views

How to write diff() mathematically?

I am using R/Python diff() operation. e.g., https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.diff.html I would like to know if there is a ...
0
votes
0answers
13 views

Combining 3 Tables with a Twist [migrated]

Let's say I have three tables: patients, samples, and mutations. The patients table has unique rows, each with a unique patient_id. The samples table has unique rows, each with a unique sample_id, ...
0
votes
0answers
15 views

how to run a generalized linear mixed model (GLMM) with multiple random factors in R? [on hold]

I would like to run a GLMM with multiple random factors using the function glmer in package lme4. I have a dataset on marine debris like this: count density: numeric year: categorical, two levels ...
0
votes
0answers
21 views

Univariate Time Series Ramp Detection

Given a univariate time series, what are common / best practice ways to detect "ramp up" or "ramp down" in a time series over an extended period of time? For example, given a daily time series of an ...
0
votes
0answers
20 views

multcomp() vs emmeans() for multiple comparisons

I have two sets of models. The first set contains a number of logistic models, fitted using glm(), with different binary dependent variables. The second set ...
0
votes
1answer
8 views

Dataset documentation and schemas [on hold]

When working with databases one typically specifies a schema, describing the data at least on a very coarse level. Often, one does not use a database, but loads the data in memory, into e.g. a pandas ...
0
votes
1answer
22 views

How to allocate unclassified observations proportionally within classified data?

In my dataset, about 30 percent of all observations belong to a unclassified category. Since I want to account for the effect of these observations, I want to allocate these unclassified observations ...
0
votes
0answers
13 views

Coding Random Forrest in R [on hold]

I'm looking to code a random forest in R but am having a bit of trouble in my dataset. Before I get into the problem, let me reproduce my code below. The response variable of interest is '...
0
votes
0answers
15 views

Calculating predicted value from polynomial regression by hand

I have the following output from from R. I know we can calculate predicted values using the predict() function. How can we calculate the predicted value by hand if X=2 or 3? I'm using the below ...