Residuals are calculated using the formula $$r_i = \frac{y_i - \hat{y}_i}{\sqrt{\hat{y}_i}}$$ which treats each element of the citation counts vector as a Poisson variate. If the expected value is zero, NA is returned. (You can decide for yourself whether to omit these observations, treat them as zero or use some other approach.)

profile_residuals(expected, observed)

Arguments

expected

Predicted vector of citations, based on some model

observed

Vector of observed citations from the journal of interest

Value

A numeric vector of standardised residuals, the same length as expected and observed

Details

We might want to make a generic S3 function like stats::residuals(). Deviance residuals may be added later. For now we have Pearson residuals only.

References

Agresti, Alan (2002). Categorical Data Analysis (2nd ed., pp. 366--367). New York, NY: Wiley.

See also

stats::rstandard.glm()

Other functions for residual analysis of communities: community_residuals, fitted_citations

Examples

# Compare citations of 'Biometrika' to those of all stats journals Bka_counts <- citations[, 'Bka'] average_profile <- rowSums(citations) / sum(citations) expected_counts <- average_profile * sum(Bka_counts) profile_residuals(expected_counts, Bka_counts)
#> AmS AISM AoS ANZS Bern BioJ #> -1.76297802 -0.98156976 4.96238240 -0.29637222 -0.92793177 -0.14562603 #> Bcs Bka Biost CJS CSSC CSTM #> -0.17154994 9.07090148 1.06660040 -0.74002496 -2.09141147 -3.34070833 #> CmpSt CSDA EES Envr ISR JABES #> -0.51850701 -3.71977308 -1.51864806 -1.38097669 -1.57856126 -1.45627202 #> JASA JAS JBS JCGS JMA JNS #> 3.69607101 -1.96056621 -2.28523373 0.05265299 -1.20560201 -1.51738180 #> JRSS-A JRSS-B JRSS-C JSCS JSPI JSS #> -1.21646075 2.28783497 1.32243924 -1.65180107 -1.65722041 -1.16262346 #> JTSA LDA Mtka SJS StataJ StCmp #> -1.96056621 1.59083358 -1.05972726 1.37141341 -1.71537471 -0.26205310 #> Stats StMed SMMR StMod StNee StPap #> -0.52327667 -3.38149096 -0.93014454 -1.48332583 -1.25061467 -1.47436305 #> SPL StSci StSin Tech Test #> -2.55171850 1.49377439 2.94127377 -1.88943431 0.26771858