statistics

R: lme, cannot evaluate groups for desired levels on 'newdata'

二次信任 提交于 2021-02-11 15:25:33
问题 I'm running an lme -model from the package nlme on R v.3.0.2. I'm trying to extract the model estimates with predict.lme , but it returns an error. Here's the code to replicate the error: my.model = lme(fixed = Maxi ~ Time*Origin, random = ~ 1 |Genotype, method = "REML", weights=varPower(), data=dd) new.my.model <- data.frame(Origin = c("Ka", "Ka", "La", "La"), Time = c("mor", "eve", "mor", "eve")) predict(my.model, new.my.model, level = 0:1) #Error in predict.lme(my.model, new.my.model,

How to extract the distance and transport matrices from Scipy's wasserstein_distance?

戏子无情 提交于 2021-02-11 14:28:16
问题 The scipy.stats.wasserstein_distance function only returns the minimum distance (the solution) between two input distributions, p and q . But that distance is the result of the product of a distance matrix and an optimal transport matrix that must have been computed inside the same function. How can I extract the distance matrix and optimal transport matrix that correspond to the solution as 2nd and 3rd output arguments? 回答1: It does not seem that you can get the calculated transport matrix

Friedman test error, possibly wrong test?

心已入冬 提交于 2021-02-11 13:50:27
问题 I have the following data: df<-structure(list(participant_id = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,

How to divide specific column with rest of columns

泄露秘密 提交于 2021-02-11 12:18:24
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide

How to divide specific column with rest of columns

拈花ヽ惹草 提交于 2021-02-11 12:17:29
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide

Seaborn : linear regression on top of a boxplot

自作多情 提交于 2021-02-11 08:46:19
问题 With seaborn, how I can use sns.boxplot and sns.lmplot to obtain a boxplot with a regression line from the same data ? This does not work : tips = sns.load_dataset("tips") ax = sns.boxplot(x="size", y="tip", data=df) ax = sns.lmplot(x="size", y="tip", data=tips, x_estimator=np.mean); 回答1: You could try the following: tips = sns.load_dataset("tips") ax = sns.boxplot(x="size", y="tip", data=df) ax = sns.regplot(x="size", y="tip", data=tips); plt.show() Instead of using lmplot you can use

What exactly does complete in mice do?

拟墨画扇 提交于 2021-02-10 17:53:05
问题 I am researching how to use multiple imputation results. The following is my understanding, and please let me know if there're mistakes. Suppose you have a data set with missing values, and you want to conduct a regression analysis. You may perform multiple imputation for m = 5 times, and for each imputed data set (5 imputed data sets now) you run a regression analysis, then "pool" the coefficient estimates from these m = 5 models via Rubin's rules (or use R package "pool"). My question is

What exactly does complete in mice do?

╄→尐↘猪︶ㄣ 提交于 2021-02-10 17:51:40
问题 I am researching how to use multiple imputation results. The following is my understanding, and please let me know if there're mistakes. Suppose you have a data set with missing values, and you want to conduct a regression analysis. You may perform multiple imputation for m = 5 times, and for each imputed data set (5 imputed data sets now) you run a regression analysis, then "pool" the coefficient estimates from these m = 5 models via Rubin's rules (or use R package "pool"). My question is

Double integration of x*np.log(x) in Python using scipy.integrate.dblquad

余生长醉 提交于 2021-02-10 14:33:11
问题 The code below uses double integration with scipy.integrate.dblquad to calculate the differential entropy, c*np.log(c) , of a copula density function c , which has one dependence parameter, theta , usually positive. Formula can be found here. import numpy as np from scipy import integrate def copula_entropy(theta): c = lambda v, u: ((1+theta)*(u*v)**(-1-theta)) * (u**(-theta) + v**(-theta) -1)**(-1/theta-2) return -integrate.dblquad(c*np.log(c), 0, 1, lambda u: 0, lambda u: 1)[0] Calling the

Calculating Confidence Interval for a Proportion in One Sample

风格不统一 提交于 2021-02-10 14:14:35
问题 What would be a better way to calculate Confidence Interval (CI) for a proportion when the sample size is small and even the sample size is 1? I am currently calculating CI for a Proportion in One Sample w/: However, my sample size is very small, sometimes it is even 1. I also tried An approximate (1−α)100% confidence interval for a proportion p of a small population using: Specifically, I'm trying to implement those two formulas to calculate the CI for proportion. As you see on the graph