[R] Count function calls

Millo Giovanni Giovanni_Millo at Generali.com
Wed Feb 27 13:40:32 CET 2013


Hello. 
Another thing you may want to do depends on whether you are using
model="within" (the default) or model="random". 

In the first case, pvcm() estimates separate regressions, so you just
need to loop lm() on individual indices to spot where it fails.

In the second case, what you may want to do is try a similar estimator:
pmg(..., model="mg"), which is an unweighted version of Swamy's
estimator in pvcm() and a simpler function to read and modify, possibly
using the global assignment operator '<<-' as already suggested by
William to output diagnostics.

Best,
Giovanni

> -----Original Message-----
> From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf
> Of Simon Zehnder
> Sent: Tuesday, February 26, 2013 2:53 AM
> To: r-help at r-project.org help
> Subject: [R] Count function calls
> 
> Dear R-users,
> 
> I have the following problem: I am running the function 'pvcm' from
the 'plm' Panel Data
> package. Inside this function 'solve' is called and gives for a
certain individual data series
> an exception because of singularity. I would like to know which
individual data series
> causes this error. I tried to debug it, but this is truly painful, as
solve is called inside of
> 'lapply' and there are over 5,000 individual data series in the panel.
> 
> Now, what I would like to do is to count the calls to 'solve' inside
the function, so I can
> see, where the function throws the exception. I tried to use 'trace'
with a count variable,
> but I have no clue how to define a global variable to be used by trace
and updated at
> every call.....is there another approach?
> 
> 
> Best
> 
> Simon
> 
> ______________________________________________

 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}



More information about the R-help mailing list