One way to do this is using ?NumericQ. Please see:

http://support.wolfram.com/kb/3820For example let's say you wanted fit a function defined by an integral to a dataset, but the integral doesn't have a symbolic solution. To do this, first write a function of the independant (exogenous/"x" ) values and the parameters that gives the dependant (endogenous/"y") values. This is the model:

f[parameter1_?NumericQ, parameter2_NumericQ.... x_?NumbericQ] := NIntegrate[......]

This function will only evaluate when it is given values for the parameters and for x, ensuring that NIntegrate will evaluate. It can be given to a function like NonlinearModelFit:

NonlinearModelFit[data, f[parameter1, parameter2.... x] , {parameter1, parameter2 ....}, x]

An example of this technique is given under the documentation for NonlinearModelFit under Generalizations & Extensions:

data = {{6.47, 3.65}, {7.43, 3.45}, {3.9, -2.94}, {4.8, -1.29}, {2.48, -0.35}, {6.32, 3.16}, {2.59, -1.19}, {9.13, -2.}, {3.81, -3.04}, {3.33, -2.68}};

(* The model is defined using NDSolve, and so we need to use NumberQ or NumericQ*)

model[a_?NumberQ, b_?NumberQ, c_?NumberQ] := Module[{y, x}, First[y /. NDSolve[{y''[x] + a y[x] == 0, y[0] == b, y'[0] == c}, y, {x, 0, 10}]]]

nlm = NonlinearModelFit[data, model[a, b, c][x], {a, b, c}, x]

Show[ListPlot[data], Plot[nlm[x], {x, 0, 10}, PlotStyle -> Green]]