statistics

How to write a loop to run the t-test of a data frame?

萝らか妹 提交于 2020-05-11 07:15:13
问题 I met a problem of running a t-test for some data stored in a data frame. I know how to do it one by one but not efficient at all. May I ask how to write a loop to do it? For example, I have got the data in the testData: testData <- dput(testData) structure(list(Label = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = c("Bad", "Good"), class = "factor"), F1 = c(0.647789237, 0.546087915, 0.461342005, 0.794212207, 0.569199511, 0

Calculate within and between variances and confidence intervals in R

自古美人都是妖i 提交于 2020-05-10 03:31:07
问题 I need to calculate the within and between run variances from some data as part of developing a new analytical chemistry method. I also need confidence intervals from this data using the R language I assume I need to use anova or something ? My data is like > variance Run Rep Value 1 1 1 9.85 2 1 2 9.95 3 1 3 10.00 4 2 1 9.90 5 2 2 8.80 6 2 3 9.50 7 3 1 11.20 8 3 2 11.10 9 3 3 9.80 10 4 1 9.70 11 4 2 10.10 12 4 3 10.00 回答1: You have four groups of three observations: > run1 = c(9.85, 9.95, 10

Calculate within and between variances and confidence intervals in R

本秂侑毒 提交于 2020-05-10 03:30:19
问题 I need to calculate the within and between run variances from some data as part of developing a new analytical chemistry method. I also need confidence intervals from this data using the R language I assume I need to use anova or something ? My data is like > variance Run Rep Value 1 1 1 9.85 2 1 2 9.95 3 1 3 10.00 4 2 1 9.90 5 2 2 8.80 6 2 3 9.50 7 3 1 11.20 8 3 2 11.10 9 3 3 9.80 10 4 1 9.70 11 4 2 10.10 12 4 3 10.00 回答1: You have four groups of three observations: > run1 = c(9.85, 9.95, 10

Linear Regression in Javascript

試著忘記壹切 提交于 2020-05-09 18:17:21
问题 I want to do Least Squares Fitting in Javascript in a web browser. Currently users enter data point information using HTML text inputs and then I grab that data with jQuery and graph it with Flot. After the user had entered in their data points I would like to present them with a "line of best fit". I imagine I would calculate the linear, polynomial, exponential and logarithmic equations and then choose the one with the highest R^2 value. I can't seem to find any libraries that will help me

Friedman test unreplicated complete block design error

会有一股神秘感。 提交于 2020-05-09 02:46:19
问题 I'm having trouble running a Friedman test over my data. I'm trying to run a Friedman test using this command: friedman.test(mean ~ isi | expId, data=monoSum) On the following database (https://www.dropbox.com/s/2ox0y1b4gwld0ai/monoSum.csv): > monoSum expId isi N mean 1 m80B1 1 10 100.000000 2 m80B1 2 10 73.999819 3 m80B1 3 10 45.219362 4 m80B1 4 10 116.566174 . . . . . 18 m80L2 2 10 82.945491 19 m80L2 3 10 57.675480 20 m80L2 4 10 207.169277 . . . . . . 25 m80M2 1 10 100.000000 26 m80M2 2 10

Friedman test unreplicated complete block design error

巧了我就是萌 提交于 2020-05-09 02:46:05
问题 I'm having trouble running a Friedman test over my data. I'm trying to run a Friedman test using this command: friedman.test(mean ~ isi | expId, data=monoSum) On the following database (https://www.dropbox.com/s/2ox0y1b4gwld0ai/monoSum.csv): > monoSum expId isi N mean 1 m80B1 1 10 100.000000 2 m80B1 2 10 73.999819 3 m80B1 3 10 45.219362 4 m80B1 4 10 116.566174 . . . . . 18 m80L2 2 10 82.945491 19 m80L2 3 10 57.675480 20 m80L2 4 10 207.169277 . . . . . . 25 m80M2 1 10 100.000000 26 m80M2 2 10

Unable to run Two-way repeated measures ANOVA; 0 (non-NA) cases

为君一笑 提交于 2020-05-08 14:44:17
问题 I am trying to follow the tutorial by Datanovia for Two-way repeated measures ANOVA. A quick overview of my dataset: I have measured the number of different bacterial species in 12 samplingsunits over time. I have 16 time points and 2 groups. I have organised my data as a tibble called "richness"; # A tibble: 190 x 4 id selection.group Day value <fct> <fct> <fct> <dbl> 1 KRH1 KR 2 111. 2 KRH2 KR 2 141. 3 KRH3 KR 2 110. 4 KRH1 KR 4 126 5 KRH2 KR 4 144 6 KRH3 KR 4 135. 7 KRH1 KR 6 115. 8 KRH2

Calculate Variance Manually in R

让人想犯罪 __ 提交于 2020-04-30 06:24:48
问题 I need your help here. I need to calculate variance manually in R. I have achieved it with this codes, it is to not robust enough for missing values and non-numeric data types. a= c(1,2,3,4,5) k=mean(a,na.rm = T) storage=a for(i in 1:length(a)) { storage[i]= ((i-k)^2) } storage =sum((storage)/(length(a)-1)) storage I run into trouble when I have a= c(1,2,3,4,5,c,NA) Please how would I edit the code? 回答1: You are using a for loop but that is really unnecessary, you can make a function to

How to write custom function from percentile_approx code which gives as equal result as percentile.inc in excel?

僤鯓⒐⒋嵵緔 提交于 2020-04-28 10:09:12
问题 I am using spark-sql-2.4.1v with Java 8. I need to calculate percentiles such as 25,75,90 for some given data. I tried using percentile_approx() from Spark-sql to do this. But the results of percentile_approx() are not matching the fractional percentiles of excel sheet which uses PERCENTILE.INC() . Hence, I'm wondering how to fix or adjust the percentile_approx() function. Is there anyway to overwrite or write a custom function modifying percentile_approx() which calculates fractional

Instance of scipy.stats.rv_discrete subclass throws error on pmf() method

限于喜欢 提交于 2020-04-21 04:40:49
问题 I want to create a subsclass of scipy.stats.rv_discrete to add some additional methods. However, when I try to access the pmf() method of the subclass, an error is raised. Please see the following example: import numpy as np from scipy import stats class sub_rv_discrete(stats.rv_discrete): pass xk = np.arange(2) pk = (0.5, 0.5) instance_subclass = sub_rv_discrete(values=(xk, pk)) instance_subclass.pmf(xk) This results in: Traceback (most recent call last): File "<ipython-input-48-129655c38e6a