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`.
24,565
questions
0
votes
0answers
3 views
Understanding how fastLink works
First of all, sorry for my English, I'm translating it with google translator.
I don't really understand how cut.p.num works.
From the manual:
...
0
votes
0answers
6 views
Unable to install the “twosamplemr” package [closed]
I was hoping someone could point out how to resolve this problem:
I first entered the following:
devtools::install_github("MRCIEU/TwoSampleMR")
Then lots ...
0
votes
0answers
8 views
GAM not actually using categorical variables?
I am very new to GAMs, but I am trying to use gam() from the mgcv package to fit a logistic regression model using cubic splines....
0
votes
0answers
10 views
Fitting GARCH model with external regressors in R
I am trying to fit a GARCH model with external regressors.
My goal is to see if the Covid-19 new cases and deaths have an effect on the volatility of daily stock returns.
For this I used the ...
0
votes
0answers
6 views
Why are the adjusted P values using the Benjamini-Hochberg procedure in dunn.test and p.adjust different?
After a Kruskal-Wallis test, I wanted to do a posthoc Dunn's test with the Benjamini-Hochberg correction, which I did with the R package dunn.test. I noticed an adjusted P-value being higher than 0.05 ...
0
votes
0answers
5 views
Test score Variable interpretation in Brandsma data (mice package)
I am currently working with the Brandsma data of the mice package in R for teaching purposes.
The dataset is from Snijders&Bosker(2012), or rather Brandsma&Knuver(1989) and Knuver&Brandsma(...
0
votes
0answers
8 views
mgcv and cyclic smoothers, am I doing it right?
TLDR: Need advice on implementation of model, particularly cyclical smoothers
I'm constructing a model that has around 3 months of daily data (a few days missing) for a response variable that falls ...
0
votes
0answers
5 views
Testing changes in regression predictors between timepoints (independent data) - regression/ANCOVA or mixed model
I have a fairly complex regression model with 14 predictors. I've collected data over five sequential (but not evenly spaced) timepoints, and I want to see whether the importance/direction of the ...
0
votes
0answers
6 views
What does “Model has aliased term(s); df ambgiuous” mean in R?
I'm trying to run crPlots and I keep getting this error
crPlots(lm_lifexp)
Error in df.terms.default(model, var) :
Model has aliased term(s); df ambiguous.
How can I solve this?
0
votes
0answers
10 views
How to calculate the effect size for the interaction term (time*Group) in a linear regression?
I need to calculate the effect size for the interaction term (time*odours) of this below linear regression. I can't use Cohen's $f^2$, as is commonly presented in a ...
0
votes
0answers
8 views
1
vote
0answers
8 views
Interpreting the covariate p-values in a multivariate generalized linear model
If a covariate in a GLM is "significant" does that mean it is significantly different from the base case (the group not shown)?
Say we have three groups, Control, Exp1, Exp2. We are ...
0
votes
0answers
27 views
How to interpret the random effect of a random slope model?
I designed an experiment to observe the shading effect in the distribution of 2 species of crabs through time. So basically I have 4 levels of shading (no shade, 20%, 50%, and 80%) with 7 ID to each (...
0
votes
0answers
11 views
What model is appropriate for flow cytometry data with dependent variable as a percentage?
I have some flow cytometry data where my dependent variable is measured as a percentage (number of cells expressing marker/total number of cells measured in that sample).
My independent variables are ...
0
votes
0answers
12 views
Pre-/Post Design controlling for pre-differences, clustering and survey weights with lmer
I'm only getting started to use R for a research project about multimorbidity in old age.
Multimorbidity was measured twice at an interval of 5 years (t1, t2) in 840 participants. There was no ...
0
votes
0answers
5 views
Theta (thetaEst) estimates in CatR with known item parameters - assessing a whole dataset
To my R angels,
After a recent voyage of discovery, I have been using IRT to develop a set of GRM derived item parameters on a large dataset of 40000 questionnaire responses.
I would like to use these ...
0
votes
0answers
13 views
Is this Fitted vs Observed diagnostic plot strange?
I am running a linear regression model in R with generalized least squares gls() on my data to fix residuals with unequal variance. I seem to have achieved this; ...
1
vote
0answers
24 views
What's the Statistical test to use to compare the means of two correlated time series (i.e., t-test for time series)?
I hope everyone is doing well. I have a question about the statistical methods of comparing two time series. I got monthly data from 1/1/2019 – 1/10/19 (10 observations). I would like to compare it to ...
0
votes
1answer
22 views
Why are variables in GLM being split into multiple output variables
I have input for glm that looks like
BMI $grp PRS age gene
24.2 1 3.0 77 0.0
33.8 1 4.0 89 0.0
30.3 1 7.0 58 0.0
I’m inputting this into ...
-1
votes
0answers
21 views
How to calculate CDF in R? [closed]
How to calculate CDF in R?
I need to calculate the cumulative distribution function of a data sample.
Is there founction to calculate value of cumulative density function in R ?
0
votes
0answers
9 views
How to do compare levels (multiple comparisons) of a factor variable when the model includes an interaction term in linear mixed models?
Hopefully, my title is not too confusing. I have two scenarios (ajo) completed after another (scen 1, scen2). A number of participants completed two scenarios in groups of four people. Each group ...
0
votes
0answers
6 views
Recovering factor level estimates from contrast estimates
Using R I have fit some data to a model of the form y~A*B where A is a factor with levels A1, A2, ..., A5 and similarly with B.
I am using a different contrast than the default, so the results do not ...
2
votes
1answer
19 views
Predictions from hurdle models in R
I am using hurdle models to predict a continuous cost variable that has many exact zeros. I have fitted a hurdle model with a binomial component and a gamma component, but when I am trying to combine ...
0
votes
0answers
8 views
Feature Engineering and prediction with R and python [closed]
I have a sequential dataset, and have 2000 rows for 300 ID. I have 20 variables (i.e in my real dataset)
...
0
votes
0answers
10 views
Accounting for unequal sample sizes - offset() code and which data to use
I have a set of data that contain two separate species placed in 4 habitat types. One of the species has 10 less organisms than the other for a particular habitat and I was hoping to account for the ...
1
vote
1answer
16 views
Random walk variance in R less than expected
I am trying to prove via some Monte Carlo simulation that the variance of a random walk equals $t*σ^2$ in R. I am running the following code, 180 times, to find the variance of 180 different random ...
1
vote
1answer
29 views
Why are my predictied values from a Bayesian AR(1) model lagging behind the data?
Summary: I have simulated some data on an AR(1) process in R and fit the model in Stan. When plotting the predictions, the predicted values tend to lag behind the true values. Why is this?
Detail
I am ...
0
votes
0answers
10 views
experimental design in R project
I want to know of any repositories that contain complete experimental design in R covering basic tests and analyses?
I want to take a top-bottom approach to learn step by step through a real project ...
0
votes
1answer
13 views
R - How to the new data set (Y) from principal component analysis (PX =Y) [closed]
I have done all my principal component analysis and have my principal components (PC1 & PC2) and I know I have to multiply that by my original data set to get my new reduced data set, but I keep ...
0
votes
0answers
5 views
Adding text to a boxplot that does not have a numbered axes [migrated]
I am interested in labeling my boxplot with the letter A in the top left corner, but because I have a categorical X axis comparing season (summer vs winter), I am unable to give coordinates for my ...
0
votes
0answers
7 views
Plot multiple imputation results from mitml [closed]
I have pooled results from the mitml package:
...
0
votes
0answers
11 views
Calculating expired vouchers, given a fixed window
Problem:
I have time series data for vouchers being earned and redeemed. Vouchers only last for a 3 day fixed window including the day they were earnt eg. a voucher earnt on 1st Jan would be active ...
0
votes
0answers
10 views
Comparing reduction rate between groups
I was wondering whether someone could help me to solve a statistical issue. I observed that by increasing an independent variable (task complexity), a dependent variable (score) decreases considering ...
0
votes
0answers
9 views
doing a cross validation mean squared error on a time series data using fable's prophet
I'm trying to do a time series cross validation with the fable prophet model on an increasing window for training and a h = 1 lag for estimation. Here's my code
...
0
votes
0answers
11 views
Seasonal time series data [closed]
I am trying to analyze data that was collected over a few decades. I have monthly data points from August through May (with a lot of data gaps and some months with multiple data collected), but ...
0
votes
0answers
23 views
How do I interpret a simple linear regression model when both dependent and independent variables are square root transformed? [duplicate]
Overview
I built a simple linear regression model to understand if Universal Healthcare Index predicts suicides.
My independent variable is Universal Healthcare Index (scale from 1 to 100). The ...
0
votes
1answer
29 views
How to interpret lm output [duplicate]
I've run the lm code below, with one DV and three IVs, and I'm not sure how to interpret the output. What does (Intercept) refer to, and what is that row telling me? What are the other rows telling ...
0
votes
0answers
7 views
How would I conduct an equivalence test in R from an lmer() model?
Lets say I have a null result, as in the following example:
library(lme4)
iris$Rand <- rnorm(150)
m <- lmer(Petal.Width ~ Rand + (1|Species), data = iris)
...
0
votes
0answers
5 views
R Library for Ordinal Regression with Split-Plot (Cluster?, Repeated Measures?) Structure
I have a data set with the following structure.
The response is ordinal.
There is an experimental factor (with two treatment levels, each treatment level applied to a different sample of subjects).
...
0
votes
0answers
9 views
Diagnostics of a parametric Survival Regression in R
I am doing a Survival Analysis in R with the "survival" package and I don't know how to do any plots of the results for diagnostic purposes.
Here is my model (I have given the variables self-...
1
vote
0answers
17 views
How to specify that I have both independent and repeated measures predictor variables in my glmer model?
I am having a little bit of trouble wrapping my head around how to specify my glmer model.
My design is as follows:
y is a binomial (Bernoulli) response variable
x1 is a categorical (factor) ...
0
votes
0answers
6 views
Test for nonlinearity in cross-sectional time series data in R
I have a cross sectional time series dataset that looks like this:
...
0
votes
0answers
8 views
Characteristic-Based Clustering of Time Series
I'm trying to teach myself how to apply clustering algorithms to time-series data. I've recently come across a paper (https://robjhyndman.com/papers/wang.pdf) about using time series characteristics ...
0
votes
1answer
27 views
Beta regression fitted values
I have a beta regression model in R, have generated predicted (fitted) values based on my data, and plotted lines of those fitted values on a scatter plot of the actual data. I'm most used to GLMMs, ...
0
votes
1answer
26 views
Including a weighting variable in a linear regression
I'm looking at how temperature affects length. My length variable is the mean length calculated for every year, it is derived from ~10,000 data points. Not every year had the same sampling effort (e.g....
0
votes
1answer
17 views
Moving average (running mean) - how to keep all observations in smoothed time-series?
Let's suppose I have a time-series of 100 daily values and I want to compute a 5-day moving average of this time series.
I would do as follows:
...
1
vote
1answer
44 views
Dealing with quasi-complete separation in General Additive Model?
I am modelling influence of fire on occurrence of certain bird species (count response variable) in Before/after control/impact experiment design. I've got intact and burned sites and count data both ...
0
votes
1answer
29 views
Combine Two Numbers that Satisfies these Five(5) Conditions with R
I want two(2) numbers $\phi_{1}, \quad \phi_{2}$ such that the following five(5) conditions will be satisfied using R:
$ \phi_{1} + \phi_{2} < 1 $
$ \phi_{1} - \...
0
votes
0answers
4 views
Question on lagging environmental variables
I am trying to test environmental variables against fish catch data to see how they impact the species composition. for environmental data, I have river discharge, temperature, rainfall, and salinity. ...
4
votes
1answer
62 views
How is this connection between Beta and Binomial possible?
I'm learning stats, and I've reasoned about this for many days and I'm losing sleep over it.
Say I have a binomial distribution B(k; n, p) simulating a hypothesis <...