Tuesday, March 24, 2015

R figure label expression

ylab=expression("UFP amount focus (# " ~ cm^-three ~ ")")

 ylab=expression(paste (PM[2.5], "mass focus (ug " ~ m^-three ~ ")"))

+labs(y=ylab)

Annotating subscript in R plots

I have to annotate one in every of my determine like this:

(b) PM2.5


And this can be a method to do it in R with ggplot2 package deal:

b ->
annotate("textual content", x=-three.5, y=zero.12, label=deparse(b),parse=TRUE)

Unsure concerning the particulars behind all of the parameters although. Because of BondedDust for answering this query.

Data and Questions: regression with factor variables

Hi my name is Kunal


I used to be taking the Knowledge Evaluation course by Jeff Leek on CourseEra.org. The video ' Regression with Issue Variables' was very helpful to me. Nevertheless, I'm a Matlab man and do not like R very a lot. So I did all of the evaluation in Matlab. The code is revealed right here:

http://matlabnewbie.blogspot.com/2014/01/matlab-code-regression-with-issue.html

and this is the video.


Matlab code: regression with factor variables

<!-- This HTML was auto-generated from MATLAB code. To make modifications, replace the MATLAB code and republish this doc. MovieData_Practice

Contents

  • Draw a scatter plot of boxoffice towards rating, grouped by score
  • Create dataset array, convert score to a nominal array
  • Queston 1 in Matlab
  • Query 2 in Matlab
  • Questions three in Matlab
  • 20/20
% Apply of Regression with categorical covariates
% By Segovia on 01/03/2014
clear;clc;shut;
load MovieData.mat

Draw a scatter plot of boxoffice towards rating, grouped by score

determine();
gscatter(rating,boxoffice, score,'bgr','x.o^');
title('boxoffice vs. rating, grouped by score')
""

Create dataset array, convert score to a nominal array

Film=dataset(boxoffice, rating,score);
Film.score=nominal(Film.score);

Queston 1 in Matlab

%Match a regression mannequin
% in 2013a model, use perform LinearModel.match
% in 2013b model, use perform fitlm
match=LinearModel.match(Film, 'rating~score')

match =


Linear regression mannequin:
rating ~ 1 + score

Estimated Coefficients:
Estimate SE tStat pValue
(Intercept) sixty seven.sixty five 7.1933 9.4046 1.7256e-sixteen
rating_PG -12.593 7.8486 -1.6045 zero.11093
rating_PG-thirteen -eleven.815 7.4113 -1.5941 zero.11323
rating_R -12.02 7.4755 -1.6079 zero.11017


Variety of observations: one hundred forty, Error levels of freedom: 136
Root Imply Squared Error: 14.four
R-squared: zero.0199, Adjusted R-Squared -zero.00177
F-statistic vs. fixed mannequin: zero.918, p-worth = zero.434

Query 2 in Matlab

%Match a regression mannequin and use "R" as reference degree in score
Movie2=Film;
Movie2.score=reorderlevels(Movie2.score, 'R','G','PG','PG-thirteen');
fit2=LinearModel.match(Movie2,'rating~score')

fit2 =


Linear regression mannequin:
rating ~ 1 + score

Estimated Coefficients:
Estimate SE tStat pValue
(Intercept) fifty five.sixty three 2.0346 27.342 four.0302e-fifty seven
rating_G 12.02 7.4755 1.6079 zero.11017
rating_PG -zero.57286 three.7411 -zero.15313 zero.87852
rating_PG-thirteen zero.20538 2.7062 zero.075893 zero.93962


Variety of observations: one hundred forty, Error levels of freedom: 136
Root Imply Squared Error: 14.four
R-squared: zero.0199, Adjusted R-Squared -zero.00177
F-statistic vs. fixed mannequin: zero.918, p-worth = zero.434

Questions three in Matlab

anova(match)

ans =

SumSq DF MeanSq F pValue
score 570.12 three one hundred ninety.04 zero.91818 zero.43398
Error 28149 136 206.ninety eight

20/20

[~,~,st]=anova1(Movie2.rating, Movie2.score,'off');
[c,m,h,nms]=multcompare(st,'show','off','ctype','hsd')

c =

1.0000 2.0000 -31.2248 -12.0200 7.1848
1.0000 three.0000 -9.0380 zero.5729 10.1837
1.0000 four.0000 -7.1578 -zero.2054 6.7470
2.0000 three.0000 -7.5703 12.5929 32.7560
2.0000 four.0000 -7.2254 eleven.8146 30.8546
three.0000 four.0000 -10.0553 -zero.7782 eight.4988


m =

fifty five.6300 2.0346
sixty seven.6500 7.1933
fifty five.0571 three.1394
fifty five.8354 1.7844


h =

[]


nms =

'R'
'G'
'PG'
'PG-thirteen'


Revealed with MATLAB® R2013a
-->

windrose plot by sigmaplot and matlab

I used two strategies to plot wind course and velocity knowledge: Sigmaplot and Matlab.
To appropriately present the wind is blowing from the diploma, say 10 diploma, I have to verify the 'clock sensible' choice. In any other case the path can be mistaken.
Once I used the wind_rose.m, which is downloaded from this hyperlink:
http://www.mathworks.com/matlabcentral/fileexchange/17748-windrose
the right method is to make use of D-one hundred eighty, and set the 'dtype' to 'meteo'.

This manner the 2 plots made by two totally different strategies can be constant and proper.

Matlab: Remove a cell element from a cell array

Just like the tactic to take away undesirable component in a matrix, which is mentioned in particulars in one other publish (http://matlabnewbie.blogspot.com/2009/07/matlab-take away-all-unwatned-parts-in.html), the undesirable cell factor could be faraway from a cell array. The one distinction is that the strcmp perform ought to be used to determine the place all these undesirable cells are.

The next instance exhibits learn how to take away the cell 'good' from the cell array a, to be by some means humble.

a=['this','is','a','good','matlab','blog'];                 % create a cell array
a=a(~strcmp(a, 'good'))                                                          % take away the 'good' cell

End result seems to be like this:


a = 

    'this'    'is'    'a'    'matlab'    'weblog'

Set the properties of a dataset array in Matlab

The % signal, %, can be utilized within the matlab code so as to add explanatory info to the code. Equally, we will add explanatory info to a dataset array, through the use of the dataset array properties. The set perform can be utilized to assign values to the dataset property, and the get perform can be utilized to entry these info.

DS=dataset(...) % a dataset array is constructed
DS=set(DS, 'Description', 'No matter can describe the dataset might be put right here');
get(DS) % present dataset array properties
abstract(DS) % additionally present dataset array properties 

The 'Description' could be changed with different properties that are displayed by the get perform.