ABCDEFGHIJKLMNOPQRSTUVWXYZ
1A simple R sheet
2This sheet attempts to illustrate many of the features of using R in a Stencila sheet - while still trying to stay relatively simple! It simulates data and fits a linear regression to it.
3
4Simulation parameters (alter these to update the simulation)Simulation function (a cell which defines the function to simulate the Y values)
5<p>Intercept (<script type="math/asciimath">a</script>)</p>0function (x) B5 + x * B6 <environment: 0x353e920>
6<p>Slope (<script type="math/asciimath">b</script>)</p>1
7<p>Variation (<script type="math/asciimath">sigma</script>)</p>1out/D7-6dc7ae1d332e618009f3362ace3e13fe.png
8
9Simulated values (applies the simulation function)
10X<p>Error (<script type="math/asciimath">epsilon</script>)</p>Y
1110.4019113949867361.40191139498674
122-0.01425933116173981.98574066883826
133-0.4597493916731412.54025060832686
1440.08985043278082984.08985043278083
1550.5116708236202545.51167082362025
166-1.505762242422654.49423775757735
1770.526467062315367.52646706231536
1881.175270603561029.17527060356102
199-0.6894926829224788.31050731707752
20101.2041925766662511.2041925766662
21
22Estimated parameters
23Intercept-0.208037207809021
24Slope1.06037220588801
25R-squared0.938870237143585
26
27Fit (uses the R `lm` function to fit a linear model)
28 Call: lm(formula = c(C11, C12, C13, C14, C15, C16, C17, C18, C19, C20) ~ c(A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)) Coefficients: (Intercept) -0.208 c(A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) 1.060
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50